Ajax updateprogress with cancellation function

Source: Internet
Author: User
ASPX page: < HTML xmlns = " Http://www.w3.org/1999/xhtml "   >
< Head runat = " Server " >
< Title > No title page </ Title >
< Script Language = " Javascript " Type = " Text/JavaScript " >  
<! --  
Function cancelasyncpostback (){
VaR PRM = SYS. webforms. pagerequestmanager. getinstance ();
If (PRM. get_isinasyncpostback ()){

PRM. abortpostback ();

}
}
//-->
</Script> 
<Style Type="Text/CSS">

# Updatepanel1 {}{

Width: 200px; Height: 100px;

Border: 1px solid gray;

}

# Updateprogress1 {}{

Width: 200px; Background-Color: # ffc080;

Bottom:0%; Left: 0px; position: absolute;

}

</ Style >
</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< Div >
< Table Style = " Width: 835px; Height: 391px " >
< Tr >
< TD Style = " Width: 100px " >
</ TD >
< TD Style = " Width: 100px " >
</ TD >
< TD Style = " Width: 100px " >
</ TD >
</ Tr >
< Tr >
< TD Style = " Width: 100px " >
</ TD >
< TD Style = " Width: 100px " >
< ASP: scriptmanager ID = " Scriptmanager1 " Runat = " Server " >
</ ASP: scriptmanager >
< ASP: updatepanel ID = " Updatepanel1 " Runat = " Server " >
< Contenttemplate >
< ASP: button ID = " Button1 " Runat = " Server " Onclick = " Button#click " Text = " Button "   />
< ASP: Label ID = " Label1 " Runat = " Server " Text = " Page Initialization " > </ ASP: Label >
</ Contenttemplate >
</ ASP: updatepanel >
< ASP: updateprogress ID = " Updateprogress1 " Runat = " Server " >
< Progresstemplate >
Processing Data. Please wait. < BR />
< Input ID = " Input1 " Type = " Button " Value = " Cancel " Onclick = " Cancelasyncpostback () " />
</ Progresstemplate >
</ ASP: updateprogress >
</ TD >
< TD Style = " Width: 100px " >
</ TD >
</ Tr >
< Tr >
< TD Style = " Width: 100px " >
</ TD >
< TD Style = " Width: 100px " >
</ TD >
< TD Style = " Width: 100px " >
</ TD >
</ Tr >
</ Table >

</ Div >
</ Form >
</ Body >
</ Html >

Aspx. CS:   Protected   Void Button#click ( Object Sender, eventargs E)
{
System. Threading. thread. Sleep ( 3000 ); // Creates a 3-second delay and displays the current time.

Label1.text =   " Page refreshed "   +

Datetime. Now. tostring ();

}

Related Article

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.