asp.net|web| Control | upload | refresh | no refresh
Share a callback based on the No Refresh Upload progress bar control of the source code. This control uses a httpmoudule based on the gem's Upload progress bar sample, which is encapsulated as a control for ease of use. Without any code, simply set web.config, add a HttpModule reference, and then drag the control onto the page. The file save operation on the page is exactly the same as the traditional asp.net file upload. You can set the property upload process error or upload success when you jump to other pages. Compatible with Ie,firefox,opera. Other environments are not tested, but because they are based on asp.net2.0 callback, other browsers should support XMLHTTP or IFRAME as long as they support it.
Online demo please visit:http://teddy.cn/test
source code and sample download Http://teddyma.cnblogs.com/Files/teddyma/TestUploadProgressBar.zip
(in the native run example note that the program's directory is set to write to the web account, otherwise the upload file will be insufficient permissions error)
Here's a short list of web.config and Default.aspx and Default.aspx.cs in the example.
Web.config
1<?xml version= "1.0"
2<configuration>
3 < Appsettings/>
4 <connectionstrings/>
5 < System.web>
6 <compilation debug= "true"/>
7 <authentication mode= "Windows"/>
8 9 <add name= "Httpuploadmodule" type= " Ilungasoft.Framework.Web.Modules.UploadProgressModule, Framework.web "/>
10 </ Httpmodules>
11 12 </system.web>
13</configuration>
Default.aspx (note line 17 You must set the uploadbuttonname of the control to the ID of the button on the page where the event will be uploaded)
1<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>
2
3<%@ Register assembly= "Framework.web" namespace= "Ilungasoft.Framework.Web.UI.WebControls"
4 tagprefix= "CC1"%>
5<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">
6http://www.w3.org/1999/xhtml">
78 <title>untitled page</title>
910<body>
One <form id= "Form1" runat= "Server" >
<div>
<asp:fileupload id= "FileUpload1" runat= "Server"/><br/>
<br/>
<asp:button id= "Button1" runat= "Server" text= "Upload"/><br/>
<br/>
<cc1:uploadprogressbar id= "UploadProgressBar1" runat= "Server" Uploadbuttonname= "Button1" Uploaderrorredir Ecturl= "Uploaderror.aspx" >
</cc1:UploadProgressBar>
<br/>
<br/>
</div>
</form>
23</body>
24Default.aspx.cs
1using System;
2using System.Data;
3using System.Configuration;
4using system.web;
5using System.Web.Security;
6using System.Web.UI;
7using System.Web.UI.WebControls;
8using System.Web.UI.WebControls.WebParts;
9using System.Web.UI.HtmlControls;
10
11public Partial class _default:system.web.ui.page
12{
protected void Page_Load (object sender, EventArgs e)
14 {
15
16}
protected void Button1_Click (object sender, EventArgs e)
18 {
Fileupload1.saveas (Server.MapPath ("test.tmp"));
20}
21}
Do you not feel like you have any more code than before using the control? ;-)
enjoy!