Saturday, October 22, 2011

How to work with AsyncFileUpload using ASP.NET AJAX


In This Tutorial We are using AsyncFileUpload of AJAX Control Toolkit which is an ASP.NET AJAX Control that allows you asynchronously upload files to server. The file uploading results can be checked both in the server and client sides.


AsyncFileUpload Events, Properties and Methods


Events 
UploadedComplete : Fired on the server side when the file successfully uploaded 
UploadedFileError : Fired on the server side when the uloaded file is corrupted


Properties 
CompleteBackColor : The control's background color on upload complete. Default value - 'Lime'. 
ContentType : Gets the MIME content type of a file sent by a client. 
ErrorBackColor : The control's background color on upload error. Default value -'Red'. 
FileContent : Gets a Stream object that points to an uploaded file to prepare for reading the contents of the file. 
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 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 object that provides access to the uploaded file. 
ThrobberID : ID of control that is shown while the file is uploading. 
UploaderStyle : The control's appearance style (Traditional, Modern). Default value - 'Traditional'. 
UploadingBackColor : The control's background color when uploading is in progress. Default value - 'White'. 
Width : The control's width (Unit). Default value - '355px'.


Methods
SaveAs(string filename) : Saves the contents of an uploaded file.



Default.aspx
(Click to enlarge Code in Image)



Default.aspx.cs
(Click to enlarge Code in Image)

Note: Try to Browse your code in Internet Explorer


View In browser:
As you can see different color every time.You can set color according to yourself, here i have set colors whose description is following.
There is no background color this shows we have not browse anything.

Uploading background color is blue at the time of file uploading

Uploading background color is green when file uploaded successfully.



Uploading background color is Red at the time of file uploading Error.



This is one of Throbbers. If you want to use different Throbber then Just Make a Search with Throbbers Keyword on Google search.
 
Throbber

No comments:

Popular Posts