Implementation of asp.net without refreshing new attachment upload

Source: Internet
Author: User

Referring to some information on the Internet recently, the client has initially reached the expected goal (the client has not found any good methods for obtaining the upload progress, but has not yet implemented it ), iframe is used to implement the resumable upload of attachments (in fact, iframe is submitted). In order to facilitate the use, it is finally made ,.. net user-defined control:

Example:

The effect of the control page is only the image of "add attachment". Run 1:

Click the image pop-up file selection box and run 2.

Open the selected file, start uploading the file, and click"Stop"Button," uploading "to" waiting for upload "," Stopping "to" uploading ", and" running 3"

Because the attachment size is limited or the page access times out, the upload fails. Run 4

The button is a server button that can be added with the js verification function:

Button1.Attributes. Add ("onclick", "return checkFileState ();");

Run 5:

Delete the file that failed to be uploaded. Run 6:

After submission, you can get the name of the uploaded attachment in cs. In Fileup. ashx, the file is renamed by time. To avoid duplication, you can add a few random numbers at the end.

Run 7:

In the cs file:
Copy codeThe Code is as follows:
Public partial class _ Default: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Button1.Attributes. Add ("onclick", "return checkFileState ();");
}
Protected void button#click (object sender, EventArgs e)
{
Response. Write (FilePostCtr1.value );
}
}

Package and download code

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.