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:
1. Create a project named webportal. In the project type, select Visual C # project or visual basic project;
2. select ASP. NET web application from the template type Program ;
3. Enter http: // localhost/webportal in the location;
4. Add a new project: The Web form named showprogress.
5. add any other Web server controls on your web form showprogress. aspx.
6. Right-click showprogress. aspx and click "View ". Code ", Enter at the top:
Visual C #. Net code
Using system. Threading;
Visual Basic. Net code
Imports system. threading
7. Enter the Visual C #. Net code in the page_load event.
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 = 'did ';");
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 = 'visible ';")
Response. Write ("window. setinterval ('showwait () ', 1000 );}")
Response. Write ("function hidewait () {mydiv. style. Visibility = 'did ';")
Response. Write ("window. clearinterval ();}")
Response. Write ("startshowwait (); </SCRIPT> ")
Response. Flush ()
Thread. Sleep (10000)
8. Enter:
<SCRIPT>
Hidewait ();
</SCRIPT>
9. Click View in the browser.
This article is transferred from Tianya technical network: www.yy0808.com. More detailed TechnologiesArticleWe hope www.yy0808.com can help our technical staff.