UpdatePanels work fine with almost all controls, one control that it does 'break' however is FileUpload. If you try and upload a file it will seem to work - but if you check FileUpload.HasFile it will always return false. Rubbish if you've got an UpdatePanel in your MasterPage! However there is a solution, in fact it's not the UpdatePanel that breaks it, but the asynchronous PostBack instead. So a neat trick is to register the button you're using to cause the upload to use a normal PostBack. This can be done as follows:

this.ScriptManager.RegisterPostBackControl(btnUpload);

Then when the user clicks the upload button they'll get a normal PostBack (and therefore an uploaded file), while all the other controls on the page will continue to operate asynchronously - no need to re-jig the whole layout of the site.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, January 23, 2008 9:53 PM | in C# .NET ASP.NET AJAX

Comments

Gravatar
# re: AJAX: FileUpload control inside an UpdatePanel
Posted by sunil
on 8/8/2008 12:30 AM
fdsfsdfdsf fgfdg

Post Comment

Title *
Name *
Email
Url
Comment *  


Please add 7 and 4 and type the answer here: