Show progress bar in asp.net

Source: Internet
Author: User
asp.net| display for asp.net pages with longer loading times, we can display a progress bar in the client browser to show that the page is loading. The following is the specific implementation process:

New project with Name Webportal, select Visual C # project in Project type or Visual Basic project;
Select the ASP.net Web application in the template type;
Position input: http://localhost/WebPortal;
Add New item: Web Form with Name ShowProgress.
Add any additional Web server controls to your Web Forms showprogress.aspx.
Right-click on the showprogress.aspx, point "View Code" and enter at the top:
Visual C #. NET code
Using System.Threading;

Visual Basic. NET code
Imports System.Threading

In the Page_Load event, enter: Visual C #. NET code
Response.Write ("<div id= ' mydiv ' >");
Response.Write ("_");
Response.Write ("</div>");
Response.Write ("<script>mydiv.innertext = ';</script>");
Response.Write ("<script language=javascript>;");
Response.Write ("var dots = 0;var Dotmax = 10;function showwait ()");
Response.Write ("{var output; Output = ' loading page ';d ots++;if (Dots>=dotmax) Dots=1; ");
Response.Write ("for" (var x = 0;x < dots;x++) {output + = ' * ';} Mydiv.innertext = output;} ");
Response.Write ("function startshowwait () {mydiv.style.visibility = ' visible ';");
Response.Write ("Window.setinterval (' showwait () ', 1000);}");
Response.Write ("function hidewait () {mydiv.style.visibility = ' hidden ';");
Response.Write ("Window.clearinterval ();}");
Response.Write ("startshowwait ();</script>");
Response.Flush ();
Thread.Sleep (10000);

Visual Basic. NET code
Response.Write ("<div id= ' mydiv ' >")
Response.Write ("_")
Response.Write ("</div>")
Response.Write ("<script>mydiv.innertext = ';</script>")
Response.Write ("<script language=javascript>;")
Response.Write ("var dots = 0;var Dotmax = 10;function showwait ()")
Response.Write ("{var output; Output = ' loading page ';d ots++;if (Dots>=dotmax) Dots=1; ")
Response.Write ("for" (var x = 0;x < dots;x++) {output + = ' * ';} Mydiv.innertext = output;} ")
Response.Write ("function startshowwait () {mydiv.style.visibility = ' visible ';")
Response.Write ("Window.setinterval (' showwait () ', 1000);}")
Response.Write ("function hidewait () {mydiv.style.visibility= ' hidden ';")
Response.Write ("Window.clearinterval ();}")
Response.Write ("startshowwait ();</script>")
Response.Flush ()
Thread.Sleep (10000)

Enter in the HTML of the Showprogress.aspx form:
<script>
HideWait ();
</script>

Point is viewed in the browser.


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.