Asp.net
<asp:FileUpload 與 UpdatePanel
我嘗試上傳多個圖像,當我上傳每個圖像時,我都會在轉發器中顯示它,但在 FileUpload1.HasFile 後面的程式碼中始終為 False ,這是我的一段程式碼:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" > <ContentTemplate> <asp:Repeater ID="rpUploadedImages" runat="server"> <ItemTemplate> <img src='../Images/<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>'/><br /> </ItemTemplate> </asp:Repeater> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnupload" EventName="click" /> </Triggers> </asp:UpdatePanel> <asp:FileUpload ID="FileUpload1" runat="server" /><br /> <asp:Button ID="btnupload" runat="server" Text="Upload" onclick="btnupload_Click" />
另一個棘手的方法是在主窗體中使用文件上傳 + 送出按鈕(或某些觸發器)創建 iframe。iframe 將回發而不影響首頁。
FileUpload 控制項不適用於 UpdatePanel,您需要進行完整的回帖才能在伺服器上獲取文件…現在有很多技巧可以使其成為 ajaxy…
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx