File upload is not working with AsyncPostBackTrigger in ASP.Net

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

I have one html file upload control to upload the profile picture and I'm using update panel and AsyncPostBackTrigger trigger. If I use PostBackTrigger then uploading of profile image works but If I use AsyncPostBackTrigger then uploading doesn't work.

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>
</asp:UpdatePanel>

Can anyone help?

Answer

Damon picture Damon · Aug 8, 2013

This is a known issue, a full postback is required for the fileupload control to work within an updatepanel i.e. you can't use a AsyncPostBackTrigger.

Edit: Just saw this is a duplicate of FileUpload Doesn't Work When Nested In UpdatePanel? C#