Need to create a PostBackTrigger for the button that initiates postback like as follows.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="True">
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text=" 上传 " OnClick="Button1_Click" />
......
</ContentTemplate>
</asp:UpdatePanel>
经验:虽然能让FileUpload在Ajax中正常使用,但这种写法页面会刷新。
参考资料:http://www.c-sharpcorner.com/uploadfile/prathore/fileupload-control-in-update-panel-using-Asp-Net-ajax/
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="True">
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text=" 上传 " OnClick="Button1_Click" />
......
</ContentTemplate>
</asp:UpdatePanel>
经验:虽然能让FileUpload在Ajax中正常使用,但这种写法页面会刷新。
参考资料:http://www.c-sharpcorner.com/uploadfile/prathore/fileupload-control-in-update-panel-using-Asp-Net-ajax/