First, add the following to the HTML document: Code:
<Div>
<Table class = "statustable">
<Tr>
<TD id = "progress1">
</TD>
<TD id = "progress2">
</TD>
<TD id = "progress3">
</TD>
<TD id = "progress4">
</TD>
<TD id = "progress5">
</TD>
<TD id = "progress6">
</TD>
<TD id = "progress7">
</TD>
<TD id = "progress8">
</TD>
<TD id = "progress9">
</TD>
<TD id = "progress10">
</TD>
</Tr>
</Table>
<Asp: Label id = "label1" runat = "server" forecolor = "red" text = "0"> </ASP: Label>
</Div>
<Div>
<Input id = "btnrequest" type = "button" value = "request" onclick = "Request ()"/>
<Input id = "btnstop" type = "button" value = "stop" Disabled = "disabled" onclick = "Stop ()"/>
</Div>
Add the following JS Code to the JS part:
<Script language = "JavaScript" type = "text/JavaScript">
VaR idx = 0;
VaR progresstimer;
VaR progressinterval = 1000;
Function request ()
{
Document. getelementbyid ("btnstop"). Disabled = "";
Document. getelementbyid ("btnrequest"). Disabled = "disabled ";
If (idx> = 10)
{
Clear ();
Return;
}
VaR Arg = idx;
<% = Clientscript. getcallbackeventreference (this, "Arg", "getmsgback", null) %>;
Idx ++;
Progresstout = setTimeout ('request () ', progressinterval );
}
Function getmsgback (result)
{
Document. getelementbyid ('progress' + idx). style. backgroundcolor = 'blue ';
VaR status = Number (result) * 10;
Document. getelementbyid ("label1"). innerhtml = status + "% ";
}
Function stop ()
{
Cleartimeout (progresstout );
Clear ();
}
Function clear ()
{
Idx = 0;
Document. getelementbyid ("btnstop"). Disabled = "disabled ";
Document. getelementbyid ("btnrequest"). Disabled = "";
Document. getelementbyid ("label1"). innerhtml = "0 ";
For (VAR I = 1; I <= 10; I ++)
Document. getelementbyid ('progress' + I). style. backgroundcolor = 'transparent ';
}
</SCRIPT>
Add the following code to the CSS style file:
. Statustable
{
Width: 100px;
Border: solid 1px #000000;
Padding-bottom: 0px;
Margin-bottom: 0px;
}
. Statustable TD
{
Height: 20px;
}
The callback code for the ASP. NET Server is as follows:
Public partial class digitstatus: system. Web. UI. Page, icallbackeventhandler
{
Private string aspeventargs;
Protected void page_load (Object sender, eventargs E)
{
}
Public void raisecallbackevent (string eventargs)
{
Aspeventargs = eventargs;
}
Public String getcallbackresult ()
{
Int I = convert. toint32 (aspeventargs );
I ++;
Return I. tostring ();
}
}
In this way, a simple progress bar is implemented, and you can get the result at the top of the page by running it.
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