用于fileupload按钮的Hasfile返回false [英] The Hasfile for the fileupload button returns false
本文介绍了用于fileupload按钮的Hasfile返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用更新面板中的文件上传按钮.第一次运行正在运行的程序时,它返回false.之后,它可以正常工作.我在回发触发器中添加了按钮.有没有解决此问题的方法.这是代码:
Hi,
I am using the file upload button inside the update panel. While running the running the program first time it returns false. After that it works fine. I have added the button in post back trigger. Is there any solution for this issue. Here is the code:
Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If Not myFileUpload.HasFile Then
lblmsg.Text = "Please select the Excel file to Import"
myFileUpload.Focus()
Exit Sub
End If
结束sub
End sub
推荐答案
请参阅此论坛.
你会得到答案
http://forums.asp.net/t/1057993.aspx/1?FileUpload + HasFile + returns + false + everytime + [ ^ ]
see this forum.
u will get answer
http://forums.asp.net/t/1057993.aspx/1?FileUpload+HasFile+returns+false+everytime+[^]
我找到了这个问题的答案.请添加以下代码以解决该问题.
Hi,
I found the answer for this issue. Please add the below code to solve the problem.
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim Form As HtmlForm = Page.Form
If Form.Enctype.Length = 0 Then
Form.Enctype = "multipart/form-data"
End If
End Sub
这篇关于用于fileupload按钮的Hasfile返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文