ASP : FileUpload control + AJAX = not-worky-work

Have been grappling with a problem relating to the ASP:FileUpload control within .NET 2.0 pages. These are heavily reliant on AJAX, including tabs, date pickers and so on. But – one tab within the page is requiring a FileUpload control – and this doesn’t work with the Save button I’ve implemented. It turns out that it’s related to the (wonderful) partial-postback aspect of AJAX :

As many people have noticed in their AJAX-enabled pages, file uploads do not work when doing an async postback.

Found this article : Why don’t file uploads work during async postbacks ?

Well – if it wants a FULL postback, I’ll friggin’ give it what it wants !! I’ve ended up implementing TWO UpdatePanels – and TWO Save buttons – as below – with one hidden / shown depending on the tab being displayed. This way, the tab that has the ASP:FileUpload control will do a full postback, and can use the file name, etc.

<asp:updatepanel ID=”mSaveUpdatePanel” runat=”server” >


            <asp:Button runat=”server” ID=”btnSave” Text=”Save” OnClick=”btnSave_Click” />




<asp:updatepanel ID=”mSaveUpdatePanelWithFullPostback” runat=”server” >


            <asp:PostBackTrigger ControlID=”btnSaveWithFullPostback” />



            <asp:Button runat=”server” ID=”btnSaveWithFullPostback” Text=”Save” OnClick=”btnSave_Click” />



Both of these “click” events call the same function, just that one uses a “PostBackTrigger”.


3 thoughts on “ASP : FileUpload control + AJAX = not-worky-work

  1. You don’t need two update panels, you just need to specify a PostBackTrigger for the file Upload button in your updatepanel.

Leave a Reply

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

You are commenting using your 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