---
title: "Ajax Toolkit AsyncFileUpload Control in ASP.Net"  
description: "AsyncFileUpload is an ASP.NET AJAX Control that allows you asynchronously upload files to server. You can save the file by calling the SaveAs () metho"  
author: "Pushpendra Singh"  
published: 2010-12-06  
updated: 2020-02-01  
canonical: https://www.mindstick.com/articles/255/ajax-toolkit-asyncfileupload-control-in-asp-dot-net  
category: "ajax"  
tags: ["ajax"]  
reading_time: 2 minutes  

---

# Ajax Toolkit AsyncFileUpload Control in ASP.Net

AsyncFileUpload is an ASP.NET AJAX Control that allows you asynchronously [upload files](https://www.mindstick.com/forum/159300/create-an-express-js-route-to-upload-files-to-the-server-using-multer-middleware) to server. You can save the file by calling the **SaveAs ()** method in a handler.\

**AsyncFileUpload [Properties](https://yourviews.mindstick.com/view/81845/now-it-s-possible-to-predict-properties-of-any-molecule):**

· **FileName** - Gets the name of a file on a client to upload using the control.

· **HasFile** - Gets a bool value indicating whether the control contains a file.

· **OnClientUploadComplete** - The name of a [javascript function](https://www.mindstick.com/forum/156513/asynchronous-javascript-function) executed in the client-side after the file successfully uploaded

· **OnClientUploadError** - The name of a javascript function executed in the client-side if the file uploading failed

· **OnClientUploadStarted** - The name of a javascript function executed in the client-side on the file uploading started

· **PostedFile** - Gets a [HttpPostedFile](https://www.mindstick.com/forum/23277/how-to-clone-a-httppostedfile) object that provides access to the [uploaded file](https://www.mindstick.com/forum/137/how-to-check-uploaded-file-type-using-asp-dot-net).

· **ThrobberID** - ID of control that is shown while the file is uploading.

## Code:

<%-- [ScriptManager control](https://www.mindstick.com/articles/250/ajax-toolkit-scriptmanager-control-in-asp-dot-net) manages client script for AJAX enabled ASP.NET pages.This enables partial-page rendering and Web-service calls.You have to used this if you want to use [ajax control toolkit](https://www.mindstick.com/articles/138/ajax-control-toolkit-confirmbuttonextender)--%>

**Step1:**write these code on [aspx page](https://www.mindstick.com/forum/218/how-do-i-create-an-aspx-page-that-periodically-refreshes-itself) we add ajax control and one label

```
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <%-- Add the AsyncFileUpload control which acces the file in asynchronous way--%>  <cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server"  CompleteBackColor="#66CCFF" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" OnLoad="AsyncFileUpload1_Load" OnUploadedFileError="AsyncFileUpload1_UploadedFileError" UploadingBackColor="#CCCCFF" /><asp:Label ID="Label1" runat="server" Text=""></asp:Label>
```

**Step2:** write the code on event load of ajax control

```
protected void AsyncFileUpload1_Load(object sender,  EventArgs e){   if (AsyncFileUpload1.HasFile) // Check the file is exist or not by using HasFile properties   {AsyncFileUpload1.SaveAs(Server.MapPath("~/UploadedFile/" + AsyncFileUpload1.FileName)); // Save the file here   }}
```

**Run the project**

![AjaxControl Toolkit AsyncFileUpload Control in ASP.Net](https://www.mindstick.com/mindstickarticle/b238f35b-b447-4446-9d04-d0f2d9aadec5/images/46336023-8918-4b60-a43c-9d463cfa9db4.png)

When you click Browse button then Browse window will open

![AjaxControl Toolkit AsyncFileUpload Control in ASP.Net](https://www.mindstick.com/mindstickarticle/b238f35b-b447-4446-9d04-d0f2d9aadec5/images/4fa90d7c-7d2a-46d8-bbf6-1b705cea401c.png)

Choose the file and click on open button

![AjaxControl Toolkit AsyncFileUpload Control in ASP.Net](https://www.mindstick.com/mindstickarticle/b238f35b-b447-4446-9d04-d0f2d9aadec5/images/1671dea1-d55b-4173-a888-68e1dacb8457.png)

File is asynchronously uploaded whenever file is selected.

---

Original Source: https://www.mindstick.com/articles/255/ajax-toolkit-asyncfileupload-control-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
