June 13, 2007

File Upload Control with Ajax update panel

FileUpload control in ASP.NET doesn't work properly on Ajax update control. It does nothing when we're try to upload a file. But you can fix that quickly just by adding a trigger to it.  check the below code...

   1:  <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
   2:                              <Triggers>
   3:                                  <asp:PostBackTrigger ControlID="Button1" />
   4:                              </Triggers>
   5:                              <ContentTemplate>
   6:                                  <asp:FileUpload ID="FileUpload1" runat="server" Width="275px" />
   7:                                  <asp:Button ID="Button1" runat="server"
   8:                                      Text="Upload" CssClass="FlatButton" OnClick="Button1_Click" />
   9:                              </ContentTemplate>
  10:                          </asp:UpdatePanel>

No comments: