Thursday, 7 November 2013

ASP.NET AjaxFileUpload Control With Progress Bar using C# or VB.NET || Drag and Drop the multiple files using AjaxFileUpload Control With Progress Bar in ASP.NET using C# or VB.NET

Hi friends,in this article I will explain about ASP.NET AjaxFileUpload Control With Progress Bar using C# or VB.NET || Drag and Drop the multiple files using  AjaxFileUpload Control With Progress Bar in ASP.NET using C# or VB.NET.
I already explained in the previous articles about Ajax AsyncFileUpload control example in asp.net to upload files to server using C#/VB.NETAjax ModalPopUpExtender Example to edit the GridView row values in ASP.NET and How to use Ajax FilteredTextBoxExtender for validating in ASP.NET

Before writing the code add reference AjaxControlToolkit.dll to your web site.

ASP.NET:
<%@Register  Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ASP.NET AjaxFileUpload Control With Progress Bar using C#/VB.NET</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>         
    <ajax:AjaxFileUpload ID="fileUpload" runat="server"
                                OnUploadComplete="fileUpload_UploadComplete" 
                                ThrobberID="progress" />
    <asp:Image ID="progress" runat="server" 
                     ImageUrl ="images/loading-gif-animation.gif"
                     Style="display:None"/>
    </div>
    </form>
</body>
</html>

In C#:NET:
using System.IO;

public partial class UploadProgressBar : System.Web.UI.Page
{
    protected void fileUpload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string path = Server.MapPath("~/Images/") + e.FileName;
        fileUpload.SaveAs(path);
    }
}
.SaveAs(path);
    }

In VB.NET:
Imports System.IO

Partial Public Class UploadProgressBar
    Inherits System.Web.UI.Page
    Protected Sub fileUpload_UploadComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AjaxFileUploadEventArgs)
        Dim path As String = Server.MapPath("~/Images/") & Convert.ToString(e.FileName)
        fileUpload.SaveAs(path)
    End Sub
End Class


The output the above code as shown in the below figure.

No comments:

Post a Comment

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.