简体   繁体   English

更新面板中的文件上载控件始终返回false

[英]File Upload control in update Panel Always returns false

I have a detailsView inside the update panel., and in the detailsView I have a FileUpload Control and a button btn_Upload . 我在更新面板中有一个detailsView 。在detailsView中,我有一个FileUpload控件和一个btn_Upload按钮。 In the click event I have written code : 在click事件中,我编写了代码:

if(fileUploadControl.HasFile)
{
    var fileName = fileUploadControl.FileName;
}

Always returns false , can some one tell me why? 总是返回false ,有人可以告诉我为什么吗?

FileUpload inside UpdatePanel will cause a submit , however it will not work for security reasons - no browser will allow javascript to access random files in our filesystem. UpdatePanel中的FileUpload会导致一个Submit,但是出于安全原因,它将无法正常工作-没有浏览器将允许javascript访问我们文件系统中的随机文件。 I suggest you use this http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/AsyncFileUpload/AsyncFileUpload.aspx instead to do what you have in mind. 我建议您改用http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/AsyncFileUpload/AsyncFileUpload.aspx来完成您要执行的操作。

Another person who has worked around this issue blogs about it here . 谁也解决此问题的博客曾它另一个人在这里

Its just a problem with the FileUpload control inside an update panel. 这只是更新面板中FileUpload控件的问题。 To get it to work you will need to do a full postback. 要使其正常工作,您将需要进行完整的回发。 Or use an alternative 或使用其他方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM