Arrabi
Arrabi

Reputation: 3768

<asp:FileUpload with UpdatePanel

Im trying tp upload more than one image, and when each one I upload I will show it in a repeater, but in the code behind the FileUpload1.HasFile is always False , this is a piece of my code :

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

Upvotes: 9

Views: 6044

Answers (2)

Bonshington
Bonshington

Reputation: 4032

Another tricky way is to create iframe with fileupload + submit button(or some trigger) inside your main form. iframe will postback with no effect to main page.

Upvotes: 3

Jaime
Jaime

Reputation: 6814

The FileUpload control does not work with UpdatePanel, you will need to do a full post back to get the file on the server... Now there are a lot of tricks to make it ajaxy...

http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx

Upvotes: 8

Related Questions