pinki
pinki

Reputation: 1418

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. In the click event I have written code :

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

Always returns false, can some one tell me why?

Upvotes: 0

Views: 1119

Answers (2)

Zasz
Zasz

Reputation: 12547

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. I suggest you use this http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/AsyncFileUpload/AsyncFileUpload.aspx instead to do what you have in mind.

Another person who has worked around this issue blogs about it here.

Upvotes: 3

WraithNath
WraithNath

Reputation: 18013

Its just a problem with the FileUpload control inside an update panel. To get it to work you will need to do a full postback. Or use an alternative

Upvotes: 1

Related Questions