AsynFileUpload – from AJAX Control Toolkit


 image

AsynFileUpload Control

The second new control included in the newest release of the AJAX Control Toolkit is the AsyncFileUpload control. You can use this control to display a fancier interface for uploading files. The AsyncFileUpload control:

  • Enables you to perform file uploads without doing a postback
  • Displays a throbber images while an image is being uploaded
  • Raises both server and client events when a file upload completes or when there is an error.
  • Works inside and outside of an UpdatePanel

Admit it! The standard file upload widget that you get with HTML is boring. You can’t display a picture while a file is uploading. And, it forces you to do a postback which is bad in this new Ajax world.

<asp:UpdatePanel ID="up1" runat="server">  
  <ContentTemplate>  
    <h1>Add File</h1>  
    File: <br />  
    <cc1:AsyncFileUpload ID="AsyncFileUpload1" onuploadedcomplete="AsyncFileUpload1_UploadedComplete" runat="server" />  
    <br /><br />  
    Description:<br />  
    <asp:TextBox ID="txtDescription" runat="server" />  
    <br /><br />  
    <asp:Button ID="btnSubmit" Text="Add File" runat="server" />  
    </ContentTemplate>  
</asp:UpdatePanel>  
public partial class TestAsnycFileUpload : System.Web.UI.Page  
{  
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)  
    {  
        System.Threading.Thread.Sleep(5000);  
        string savePath = MapPath("~/Uploads/") + Path.GetFileName(e.filename);  
        AsyncFileUpload1.SaveAs(savePath);  
    }  
}
  

Via New AJAX Control Toolkit Release

Advertisements

One thought on “AsynFileUpload – from AJAX Control Toolkit

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s