Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.Net文件上载导致使用触发器在更新面板中发回_Asp.net_File Upload_Updatepanel_Postback_Asyncfileupload - Fatal编程技术网

ASP.Net文件上载导致使用触发器在更新面板中发回

ASP.Net文件上载导致使用触发器在更新面板中发回,asp.net,file-upload,updatepanel,postback,asyncfileupload,Asp.net,File Upload,Updatepanel,Postback,Asyncfileupload,我有文件上传控制上传个人资料图片使用更新面板。我在更新面板中使用了AsyncPostBackTrigger,但页面仍然会导致完全回发 <asp:UpdatePanel ID="pnlZerkerBasicProfile" runat="server"> <ContentTemplate> <input type="file" id="myFile" name="myFile" class="file_input_hidden"

我有文件上传控制上传个人资料图片使用更新面板。我在更新面板中使用了AsyncPostBackTrigger,但页面仍然会导致完全回发

<asp:UpdatePanel ID="pnlZerkerBasicProfile" runat="server">
   <ContentTemplate>
      <input type="file" id="myFile" name="myFile" class="file_input_hidden" 
             onchange="javascript:FileUploadSubmit();" style="cursor: pointer;" />
      <asp:Button ID="btnSaveProfilePicture" runat="server"Text="Upload" 
           OnClick="btnSaveProfilePicture_Click" />
   </ContentTemplate>
   <Triggers>
       <asp:PostBackTrigger ControlID="btnSaveProfilePicture"  />
   </Triggers> 
</asp:UpdatePanel>
下面是我的内联代码

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


有人能帮忙吗?

将触发器更改为回发触发器,因为当通过更新面板进行异步回发时,Request.Form.AllKeys中不提供文件上载。见此:

这应该行得通

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
            <Triggers>
                <asp:PostBackTrigger ControlID="Button1" />
            </Triggers>
            <ContentTemplate>
                 <asp:FileUpload ID="FileUpload1" runat="server" />
                 <asp:Button ID="Button1" runat="server"Text="Upload" OnClick="Button1_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>

此代码应该有效。它不会导致回发

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

谢谢您的回答,但我不想发回页面。还有别的选择吗?