Skip to main content

Posts

Showing posts from April, 2008

How to use standard FileUpload in AJAX-enabled web applications

I would like to note that this article is not about the ability to upload files to the server without the postback. There are a lot of articles on this topic, just type "AJAX FileUpload" on any search engine and you'll get many examples. However with AJAX they actually have little in common, because the XMLHttpRequest does not support asynchronous uploading of files to the server, they are rather a variety of imitations, for example, using hidden IFRAME element. Nevertheless I want to emphasize that the article is not about that but about the standard FileUpload control.

There are two problems you might encounter when using it on UpdatePanel.

Problem 1
If the postback is caused by the control which lies on UpdatePanel, FileUpload is always empty when it has come to the server, regardless whether a file has been selected or not.
Example:<asp:UpdatePanel ID="UpdatePanel1" runat=server>
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" r…