Tuesday, 10 June 2014

Ajax FileUpload Control In Asp.Net or Multiple FileUpload With Progress Example in Asp.Net Using C#.Net

6/10/2014 - By Pranav Singh 19

In this article I will show you how you can perform ajax file upload in your application. In this article I have used Asp.Net, AjaxFileUpload, and C#.Net.

So for this article first you needed to create a new application and add AjaxFileUpload control, and script manager. After adding the controls your page will look as shown below.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxFileUpload.aspx.cs"
    Inherits="" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Ajax FileUpload Control In Asp.Net or Multiple FileUpload With Progress Example
        in Asp.Net</title>
    <form id="form1" runat="server">
        Ajax FileUpload
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <asp:AjaxFileUpload ID="AjaxFileUpload11" runat="server" MaximumNumberOfFiles="10"
        OnUploadComplete="AjaxFileUploadEvent" Width="500px" />

In above code we have set some property for the AjaxFileUpload.  They are as follows:
MaximumNumberOfFiles : In this we have defined the maximum no of files to be allowed to upload at a time.
OnUploadComplete: In this we will define the upload function as an event to upload the file in specified folder.
Width: In this we will define the control width.

Now here is the server code which we will used  for saving the uploaded file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

    public partial class AjaxFileUpload : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        protected void AjaxFileUploadEvent(object sender, AjaxFileUploadEventArgs e)
            string filename = System.IO.Path.GetFileName(e.FileName);
            string strUploadPath = "~/Folder/";
            AjaxFileUpload11.SaveAs(Server.MapPath(strUploadPath) + filename);

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports AjaxControlToolkit

    Partial Public Class AjaxFileUpload
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        End Sub
        Protected Sub AjaxFileUploadEvent(ByVal sender As Object, ByVal e As AjaxFileUploadEventArgs)
            Dim filename As String = System.IO.Path.GetFileName(e.FileName)
            Dim strUploadPath As String = "~/Folder/"
            AjaxFileUpload11.SaveAs(Server.MapPath(strUploadPath) + filename)
        End Sub
    End Class
End Namespace

Now what you think you will be able to upload the file. No you will not be able to upload the file it will cause error while uploading the files.

So for successful upload we will add an event handler in our web.config file

<?xml version="1.0"?>
      <add verb="*" path="AjaxFileUploadHandler.axd"

Now we will create folder in our solution.

Now we have done. View the page in browser you will

After success full upload let’s check the folder weather files have actually uploaded or not. 

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post


  1. Please let me know you comment..

    1. best way for uploading multiple files with ajax fileupload control

  2. using AjaxControlToolkit;
    makes Error,
    Where I will get the assemby sir

    1. Hi Sagar
      First thanks for posting your comment. for getting AjaxcontrolToolkit reference you need to download AjaxcontrolToolkit library from website. please check the link. in this download you will get AjaxcontrolToolkit .dll .

  3. Hi sagar this link may help you please check

  4. The name of the event is 'OnClientUpdateComplete' and not 'OnUploadComplete' in Version 3.5 and 4.0. Control does not render when I define a function for this event, only black box ist displayed, found out the website raises javascript error about a mission function then.
    Also the control needs the TolkitScriptManager in order to run properly.
    Ether there is something mystic involved or the control is broken! Cant go deeper in this, wasted my whole workday on this!!!

    1. Hi, The above provided is working file. after your comment i am attaching the demo of the article. please check the link. If you are getting error. it may happen that your library is not proper please download it again or you are missing your web.config setting which is

      demo download :

    2. please check the web.config configuration mention in above article.

  5. follow this great example

  6. see this is very good and easier way for multiple file uploading

  7. Hi when i try to execute the above program i am getting the following error
    HTTP Error 500.23 - Internal Server Error
    An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
    I am using ajaxcontrolToolkit 4.5
    Please tell me how to solve this error

    1. Hi please check the some of the solution for the error.

  8. hi, I am able to upload the files locally on my PC. but on the web server, I see it goes to 100%, and then errored.

  9. Hi, I got this error when loading the aspx page.
    Parser Error Message: Could not load type 'AjaxControlToolkit.AjaxFileUploadHandler' from assembly 'AjaxControlToolkit'.
    Source error:
    Line 13:
    Line 14:
    Line 15:

    1. Hi
      Please check the below mention link for solution.

  10. Hi
    i am not able to upload ,whenever i click on upload button nothing is happening, I have written handlers also in web .config ,but then also nothing is happening.

  11. In IE browser i can't see drag and drop option from one server where as same configuration working fine in different server. even its not displaying drag and drop box. both servers are windows 2008.

    Any section is blocking in the server.


Please let me know your view

Free Ebooks

About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

Email Id :

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at


Top jQuery Plugins

Global Classified :
© 2014
back to top