Ajax based FileUploading

16 06 2008

I had an ajax based asp.net page which was working perfectly and i was happy. On same page when i put a file upload control the whole page becomes non-AJAX.

During search on GOOGLE, I found that you can not make the file uploader AJAX BASED. However what you can is that, you can enforce a “FULL POST BACK” for file uploader. In this way all other things on page remains ajax based.

TO do this, just do as follow

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
      <asp:FileUpload ID="FileUpload1" runat="server" />
      <asp:Button ID="btnUploadFile" runat="server" Text="Upload" />
In above snip est, you have a file upload control and a button btnUploadFile which will perform file upload.

You have to write a postback trigger on this button to enable full postback

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
    <asp:PostBackTrigger ControlID="Button1" />

This is  all which you have to do to make your page AJAX ENABLED with FILEUPload.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: