Help us to translate this website and improve this translation!
English | Castellano

How to Use the FileUpload AJAX Control

FileUploadAJAX Options

Obviously, if you want, FileUploadAJAX can be used simultaneously in several pages or inside the same page. Only when placing the FileUploadAJAX inside a control of repetition (gridview, datalist, repeater...) will you encounter problems.




Code.aspx
<table width="100%">
    <tr>
       <td width="50%">
          <cc1:FileUploaderAJAX ID="FileUploaderAJAX3" runat="server" MaxFiles="3" />
       </td>
       <td width="50%">
          <cc1:FileUploaderAJAX ID="FileUploaderAJAX4" runat="server" MaxFiles="4" />
       </td>
    </tr>
</table>

<cc1:FileUploaderAJAX ID="FileUploaderAJAX1" runat="server" MaxFiles="5" />
Code.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
   if (FileUploaderAJAX1.IsPosting)
       this.managePost1();

   if (FileUploaderAJAX2.IsPosting)
       this.managePost2();
}

private void managePost1()
{
   HttpPostedFileAJAX pf = FileUploaderAJAX1.PostedFile;

   if (pf.ContentType.Equals("image/gif") && pf.ContentLength <= 5 * 1024)
       FileUploaderAJAX1.SaveAs("~/temp", pf.FileName);
}

private void managePost2()
{
   HttpPostedFileAJAX pf = FileUploaderAJAX2.PostedFile;

   if (pf.ContentType.Equals("image/gif") && pf.ContentLength <= 5 * 1024)
       FileUploaderAJAX2.SaveAs("~/temp", pf.FileName);
}