ASP. net2.0: ilungasoft. Framework. Web-based callback-based Brushless new upload progress bar control [with source code]

Source: Internet
Author: User
Share the source code of a callback-based update progress bar control. The httpmoudule used by this control is based on the sample of an upload progress bar of Baoyu. It is encapsulated as a control for ease of use. No code is required. You only need to set web. config, add the reference of httpmodule, and drag the control to the page. The file storage operation on the page is exactly the same as that on the traditional Asp.net file upload. You can set the property to jump to another page when an error occurs during the upload process or the upload is successful. Compatible with IE, Firefox, and opera. Other environments are not tested, but because they are based on ASP. net2.0 callback, other browsers should support XMLHTTP or IFRAME.

Online Demo visit: http://teddy.cn/test

Download source code and example
(For example running on the local machine, set the directory where the program is located to writable to the Web account. Otherwise, an error is reported if the file to be uploaded has insufficient permissions)

Below is a simple example of Web. config and default. aspx and default. aspx. CS.

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 11 12 </system. Web>
13 </configuration>

Default. aspx (note that the uploadbuttonname of the control must be set to the name attribute of the input tag generated when the button for the departure upload event is running on the page. The name may be like ctl00 $ contentplaceholder1 $ button1) when the template page is contained)

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 = "maid" %>
5 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <HTML xmlns = "http://www.w3.org/1999/xhtml">
7 8 <title> untitled page </title>
9 10 <body>
11 <Form ID = "form1" runat = "server">
12 <div>
13 <asp: fileupload id = "fileupload1" runat = "server"/> <br/>
14 <br/>
15 <asp: button id = "button1" runat = "server" text = "Upload" onclick = "button#click"/> <br/>
16 <br/>
17 <PC3: uploadprogressbar id = "uploadprogressbar1" runat = "server" uploadbuttonname = "button1" uploaderrorredirecturl = "uploaderror. aspx">
18 </PC3: uploadprogressbar>
19 & nbsp; <br/>
20 <br/>
21 </div>
22 </form>
23 </body>
24 Default. aspx. CS

1 using system;
2 using system. Data;
3 using system. configuration;
4 using system. Web;
5 using system. Web. Security;
6 using system. Web. UI;
7 using system. Web. UI. webcontrols;
8 using system. Web. UI. webcontrols. webparts;
9 using system. Web. UI. htmlcontrols;
10
11 public partial class _ default: system. Web. UI. Page
12 {
13 protected void page_load (Object sender, eventargs E)
14 {
15
16}
17 protected void button#click (Object sender, eventargs E)
18 {
19 fileupload1.saveas (server. mappath ("test. tmp "));
20}
21}

Didn't you feel any more code than before using the control ?; -)

Enjoy!
Http://teddyma.cnblogs.com/archive/2006/04/01/364171.html

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.