Sunday , 23 November 2014
You are here: Home » .NET » Use AjaxFileUpload Control in Visual Studio 2012

Use AjaxFileUpload Control in Visual Studio 2012

While developing a project you might come across a situation where you need to upload multiple files at a time. If you working on Asp.net project and you come across similar situation no need to worry you have nice options to accomplish this task.

We can make use of AjaxFileUpload Control. It offers several features.

1. Upload multiple files at a time.

2. Progress bar to display file upload status.

3. Drag and drop facility.

In order to use AjaxFileUpload control first you need to add AjaxControlToolkit to your application, wanted to learn how to do it? Please refer my previous post on How to add AjaxControlToolkit to Visual Studio 2012.

The best part of this control is you can control which file types you want to upload. You can make use of AllowedFileTypes property. You can simply allow different file types separated by commas in AllowedFileTypes control.

AjaxUpload

 

Using this Control is very simple you just need  to drag this control from ToolBox and drop it on your .aspx page, add directive to register assembly and add script manager and you are all set to use AjaxFileUpload control. Registering assembly and adding script manager shown in code given below.

 ASP |  Copy to Clipboard |? 
1
// Register Assembly
2
< %@&nbsp;Register&nbsp;assembly="AjaxControlToolkit"&nbsp;namespace="AjaxControlToolkit"&nbsp;tagprefix="asp"&nbsp;%>
3
 
4
//&nbsp;Add&nbsp;Script&nbsp;Manager
5
<asp:scriptmanager &nbsp;Id="Scriptmanager1"&nbsp;runat="server"></asp:scriptmanager>
6
 
7
//&nbsp;AjaxFileUpload&nbsp;Control
8
<asp:ajaxfileupload &nbsp;ID="AjaxFileUpload1"&nbsp;runat="server"></asp:ajaxfileupload>

AjaxFileUpload Control Properties :

  • ThrobberID - The ID of a control that is shown while the file is uploading. The throbber image is displayed for browsers that do not support the HTML5 File API.
  • ContextKeys - A dictionary that can be used to pass information to the server when a file is uploaded.
  • MaximumNumberOfFiles - This property enables you to limit the number of files that a user can add to the upload queue.
  • AllowedFileTypes - This property enables you to restrict the types of files that can be uploaded. You can assign a comma delimited list of file extensions to this property.
  • IsInFileUploadPostBack - This property has the value true when a page is created in response to an AjaxFileUpload asynchronous postback.
  • OnClientUploadComplete - The name of a JavaScript function executed in the client-side after a file is uploaded successfully.
  • OnClientUploadError - The name of a JavaScript function executed in the client-side if the file upload failed.

About Vinayak Bamane

MCA from IMCOST College. Works as a Software Specialist with eClinicalWorks. Programming Worm, Trek lover, Rock Climber, Game Addict, Volleyball Player and happy to be with Amazing Things : )
Scroll To Top