ASP. NET Ajax asyncfileupload control usage

Source: Internet
Author: User
ASP. NET Ajax asyncfileupload control usage Time: Source:Unknown Author:Admin Click:254 times I want to contribute High-quality ASP. NET space, perfect support for 1.0/2.0/3.5/MVC, etc.

The asyncfileupload control is used to asynchronously upload files. For example, refer to: Upload. If you need to upload files asynchronously, refer to the following usage:

 

Front-end code:

 

<Ajaxtoolkit: asyncfileupload onclientuploaderror = "uploaderror" onclientuploadcomplete = "uploadcomplete"
Runat = "server" id = "asyncfileupload1" width = "400px" uploaderstyle = "modern"
Uploadingbackcolor = "# ccffff"
Onuploadedcomplete = "asyncfileupload1_uploadedcomplete"/>

 

Let's talk about attributes,

Onclientuploaderror: client Error Handling Method

Onclientuploadcomplete: client upload completion event

Uploaderstyle: control style, either traditional or modern

Onuploadedcomplete: Specifies the storage location and name of a file by calling the saveas method.

 

Front-end JS Code:

 

Function uploadcomplete (sender, argS ){
Alert ("uploaded successfully ");
}

Function uploaderror (sender, argS ){
Alert ("Upload error ");
}

 

Background code:

 

Protected void asyncfileupload1_uploadedcomplete (Object sender, ajaxcontroltoolkit. asyncfileuploadeventargs E)
{
Ajaxcontroltoolkit. asyncfileupload fileuploader = sender as ajaxcontroltoolkit. asyncfileupload;
If (fileuploader! = NULL & fileuploader. hasfile)
{
Fileuploader. saveas (server. mappath ("/resource/uploadfile/" + fileuploader. filename ));
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.