Home | Projects | Tutorials | Articles | live chat | Submit Project | Big Vote
 
Ajax Projects
.NET Frameworks
Java Frameworks
PHP Frameworks
Ruby Frameworks
Other Frameworks
Cool AJAX sites
Ajax Resources
Ajax Tools
JavaScript frameworks

 Home /  Tutorials / Asp.net Asyncfileupload

Asp.net Asyncfileupload





AsyncFileUpload is a new ASP.NET AJAX Control that allow you upload files to server.Here is the Html code you can add to add the AsyncFileUpload control:

Read The Full Tutorial.
































AsyncFileUpload is a new ASP.NET AJAX Control that allow you upload files to server.Here is the Html code you can add to add the AsyncFileUpload control:

<asp:ScriptManager ID="ScriptManager1" runat="server">


</asp:ScriptManager>


<cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" CompleteBackColor="White"


OnUploadedComplete="AsyncFileUpload1_UploadedComplete" OnUploadedFileError="AsyncFileUpload1_UploadedFileError"


OnClientUploadComplete="Success" OnClientUploadError="Error" />


<asp:Label ID="Label1" runat="server"></asp:Label>

Server side events:

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)


{


 //Fired on the server side when the file successfully uploaded


   if (AsyncFileUpload1.HasFile)


   {


         AsyncFileUpload1.SaveAs(@"C:\Images\" + AsyncFileUpload1.FileName );


         Label1.Text = "Received " + AsyncFileUpload1.FileName + " Content Type " + AsyncFileUpload1.PostedFile.ContentType ;


   }


 }

Client side events:

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

OnClientUploadComplete - The name of a javascript function executed in the client-side on the file uploading completed

function Success() {


document.getElementById("Label1").innerHTML = "File Uploaded Successfully !!";


}


function Error() {


document.getElementById("Label1").innerHTML = "File upload failed";


}

We can use  OnClientUploadComplete to clear fileupload control selction,

function Success() {

document.getElementById ("Label1").innerHTML = "File Uploaded Successfully !!";

var fu = document.getElementById("AsyncFileUpload1");

document.getElementById("AsyncFileUpload1").innerHTML = fu.innerHTML;

}



protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)


 {


 //Fired on the server side when the loaded file is corrupted


 //Display some error message here


 }
Server side events:

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)


{


 //Fired on the server side when the file successfully uploaded


   if (AsyncFileUpload1.HasFile)


   {


         AsyncFileUpload1.SaveAs(@"C:\Images\" + AsyncFileUpload1.FileName );


         Label1.Text = "Received " + AsyncFileUpload1.FileName + " Content Type " + AsyncFileUpload1.PostedFile.ContentType ;


   }


 }


protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)


 {


 //Fired on the server side when the loaded file is corrupted


 //Display some error message here


 }
AddThis Social Bookmark Button
Top Projects
MSN Web Messenger
MessengerFX
ebuddy
e-messenger
ILoveIM
You Tube
AJAX file upload
KoolIM.com
Meebo
Ajax.NET Professional
Tutorials
Installing og/Nitro using Rubygems
ASP.NET 2.0 Script CallBack ( AJAX like)
Caching AJAX Results in Javascript
Using the Microsoft Ajax Library 3.5 with the CDN
Object Killing in IE7
Stylize Forms With CSS
ASP.NET MVC and JSON
Ajax Page Loads Using MooTools Fx.Explode
Facebook Chat API
How To Create Css Search Box and Button