Thursday, June 11, 2009

FileUpload Control in Update Panel using ASP.NET AJAX

FileUpload control will not work inside an UpdatePanel control for uploading files using Asynchronous postback. This is because, the file uploading and file manipulations is restricted by default in client side for security reasons. Hence it is not possible to upload files using asynchronous postback in UpdatePanel.

All file upload controls does not working in any ajax update panel and upload control needs to full page postback. This means if your upload control located in an update panel, control does not post the file. If you look to the posted file property of the control, you will see it null. So, the control always have to post full page postback.

To resolve this problem we need to rely upon a standard postback i.e. we need to set the button that is uploading the file to be PostBack trigger instead of AsyncPostBack trigger. This will initiate a normal postback whenever we click the upload button and it is possible to upload the file.

You need to create a PostBackTrigger for the button which should initiate postback like as follows.


See full detail: http://www.c-sharpcorner.com/UploadFile/prathore/FileUpload04292009022804AM/FileUpload.aspx