Tuesday, December 15, 2009

FileUpload control does not work in Update Panel : solution

All file upload controls (includes asp, telerik, componentart, component factory and others) does not working in any AJAX update panels. 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.

This is a 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.

The solution is to add a Triggers tag:

<asp:UpdatePanel ID="upFileUpload" runat="server" >

<Triggers>

<asp:PostBackTrigger ControlID="btnUpload" />

</Triggers>

<ContentTemplate > .....

</ContentTemplate>

</asp:UpdatePanel>

See it work like a charm!!

No comments: