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”.