ASP.Net file upload causing post back in update panel using triggers

Dhaval Panchal picture Dhaval Panchal · Aug 8, 2013 · Viewed 9.6k times · Source

I have file upload control to upload the profile picture using update panel. I have used AsyncPostBackTrigger with update panel but still the page is causing full postback.

Below is my code inline.

<asp:UpdatePanel ID="pnlZerkerBasicProfile" runat="server">
<input type="file" id="myFile" name="myFile" class="file_input_hidden" onchange="javascript:FileUploadSubmit();" style="cursor: pointer;" />
<Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSaveProfilePicture" />
</Triggers>

Can anyone help?

Answer

user2706869 picture user2706869 · Aug 22, 2013

change the trigger t a postback trigger since file upload is not available in Request.Form.AllKeys when async postback occurs via update panel. See this:

http://www.codeproject.com/Articles/16945/Simple-AJAX-File-Upload