For ASP. NET pages that have been loaded for a long time, we can display a progress bar in the client browser to show that the page is being loaded. The specific implementation process is as follows:
Create a project named WebPortal. In the project type, select Visual C # project or Visual Basic project;
Select an ASP. NET Web application from the template type;
Enter: http: // localhost/WebPortal;
Add a new project: A Web form named ShowProgress.
Add any other Web server controls on your Web form ShowProgress. aspx.
Right-click ShowProgress. aspx, click "view code", and enter:
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'; dots ++; 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 = 'ddn'; "); 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'; dots ++; 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 = 'visable'; ") Response. write ("window. setInterval ('showwait () ', 1000);} ") Response. write ("function HideWait () {mydiv. style. visibility = 'hiddy'; ") Response. write ("window. clearInterval ();} ") Response. write ("StartShowWait (); </script>") Response. flush () Thread. sleep (10000) in ShowProgress. input in the html of the aspx form: <script> HideWait (); </script>
Click View in the browser.