File upload is not working with AsyncPostBackTrigg

2019-07-26 09:55发布

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?

1条回答
看我几分像从前
2楼-- · 2019-07-26 10:30

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#

查看更多
登录 后发表回答