FileUpload and Ajax UpdatePanel

All file upload controls (includes asp, Telerik, component, component factory and others) does not work in any ajax update panel and upload control needs to full page postback. This means if your upload control located in an update panel, the control does not post the file. If you look at the posted file property of the control, you will see it null. So, the control always has to post full page postback.

This is limitation comes from the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application. In order to upload a file, you should perform a full page postback.

If you have an automatically AJAX-enabled button or other control, which normally does postbacks, placed in UpdatePanel you could use one of the following workarounds to make the button perform postbacks again.

1 - You need to create a PostBackTrigger for the button which should initiate postback.

<asp:updatepanel runat="server" id="UpdatePanel1">
           <asp:FileUpload runat="server" id="Upload1" />
           <asp:button runat="server" id="ButtonSubmit" text="Postback" />
           <asp:postbacktrigger controlid="ButtonSubmit" />
  • You can register the page and control to do full page postback. To do this, you can use the script manager. (suggested by EtienneT)
  • You can use the “iframe” HTML object to call upload webpage in the frame. But this as you know iframe is not an XHTML object. But this can be the smooth fix for you. (suggested by Justin Bozoiner)
Next Post Previous Post
No Comment
Add Comment
comment url