In a Web application, a message must be displayed when some operations take a long time, prompting the user to wait. The following code is a simple javascript example. Of course, it is not a real progress bar.
Put a Label, a Button,
Then add the javascript code in a separate js file. The Code is as follows: var flag = "0 ";
Function showProcess ()
{
Window. setTimeout ('showmsg () ', 1 );
}
Function showMsg ()
{
Var msg = document. getElementById ("Label1 ");
Msg. style. color = "blue ";
If(zookeeper Doc ument. readyState! = Null&{doc ument. readyState! = 'Complete ')
{
If (flag = 0)
{
Flag = 1;
Msg. innerHTML = "Please wait .";
}
Else if (flag = 1)
{
Flag = 2;
Msg. innerHTML = "Please wait ..";
}
Else
{
Flag = 0;
Msg. innerHTML = "Please wait ...";
}
Window. setTimeout ('showmsg () ', 500 );
}
Else
{
Msg. innerHTML = "";
Flag = 0;
}
}
REFERENCE The js file on the aspx page:
<SCRIPT language = "javascript" src = "JScript. js" type = "text/Jscript"> </SCRIPT>
In the cs file of the page, add the Event code to the Button: protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
This. Button1.Attributes. Add ("OnClick", "showProcess ();");
}
}
Protected void button#click (object sender, EventArgs e)
{
For (int I = 0; I <= 500000000; I ++)
{
}
// Response. Redirect ("werwer. aspx ");
}
Now you can run it to check the effect.