Recent reference to some information on the Web, initially reached the expected target (client access to upload progress, not found any good method, no implementation), the use of IFRAME to achieve the attachment of no refresh upload effect (in fact there are submitted IFRAME), in order to use convenient, and finally made,. NET user-defined control:
Control Use Examples:
Control page Effect just "add attachment" picture, run effect chart one:
Click on the picture pop-up file selection box, run effect figure two
Select File Open, file start upload, click the " Stop" button, "uploading" into "waiting to upload", "Stop" into "upload", the operation effect figure three
The upload failed because the size of the attachment is limited or page access timed out, and the effect figure four
button buttons are server buttons that can be added to the JS validation function for a duration:
BUTTON1.ATTRIBUTES.ADD ("onclick", "return Checkfilestate ();");
Run effect Figure five:
Delete Upload failed file, run effect Figure VI:
After submission, you can get to upload the name of the successful attachment in the CS, in the FILEUP.ASHX is the time to rename the file, in order to avoid duplication can be added after a few random number.
Run Effect Figure VII:
In the CS file:
Copy Code code 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 Button1_Click (object sender, EventArgs e)
{
Response.Write (Filepostctr1.value);
}
}
Code package download