Here i have explained how to use AsyncFileUpload control in Asp.net with Example.

Step 1) Add HTML:

<form id="form1" runat="server">

<ajax:ToolkitScriptManager ID="scriptManager1" runat="server"/>

<ajax:AsyncFileUpload ID="fileUpload1" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError" 
CompleteBackColor="White" Width="350px" runat="server" UploaderStyle="Modern" UploadingBackColor="#CCFFFF" 
ThrobberID="imgLoad" OnUploadedComplete="fileUploadComplete" /><br />
<asp:Image ID="imgLoad" runat="server" ImageUrl="loading.gif" />
<br />
<asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>

</form>

Step 2) JavaScript

// This function will execute after file uploaded successfully
function uploadComplete() {
document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "File Uploaded Successfully";
}
  
// This function will execute file upload fails
function uploadError() {
document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "File upload Failed.";
}

Step 3) C#

Import Namespaces

using System;
using System.Threading;
using System.Web.UI;
using AjaxControlToolkit;
 protected void fileUploadComplete(object sender, AsyncFileUploadEventArgs e)
    {
        Thread.Sleep(1000);
        string filename = System.IO.Path.GetFileName(fileUpload1.FileName);
        fileUpload1.SaveAs(Server.MapPath("FolderName/") + filename);
    }

Screenshot

Add Comments