Cancel updating (cancel the updating of updatepanel) of updatepanel)

Source: Internet
Author: User

When updatepanel is used for partial refresh, sometimes it takes a long wait time. At this time, if there is a "cancel" button, it can provide a lot of convenience for human-computer interaction.

In the followingCode.

 

< Script Language = "JavaScript" Type = "Text/JavaScript" >
<! --  
VaR PRM = SYS. webforms. pagerequestmanager. getinstance ();
Function Cancelasyncpostback (){
If (PRM. get_isinasyncpostback ()){
PRM. abortpostback ();
}
}
// -->
</ Script >

 

Next, use an HTML control to call this js method to complete the "cancel" effect. All the code is as follows:

 

Code
<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Abortpostback. aspx. CS " Inherits = " Abortpostback "   %>

<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > Untitled page </ Title >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >

< ASP: scriptmanager ID = "Scriptmanager1" Runat = "Server" >
</ ASP: scriptmanager >
< Script Language = "JavaScript" Type = "Text/JavaScript" >
VaR PRM = SYS. webforms. pagerequestmanager. getinstance ();
Function Cancelasyncpostback (){
If (PRM. get_isinasyncpostback ()){
PRM. abortpostback ();
}
}
</ Script >

< ASP: updatepanel ID = "Updatepanel1" Runat = "Server" >
< Contenttemplate >
< ASP: button ID = "Button1" Runat = "Server" Text = "Update" Onclick = "Button#click"   />
< ASP: textbox ID = "Textbox1" Runat = "Server" > </ ASP: textbox >
</ Contenttemplate >
</ ASP: updatepanel >
< ASP: updateprogress ID = "Updateprogress1" Runat = "Server"  
Associatedupdatepanelid = "Updatepanel1" >
< Progresstemplate >
Updating. < Input ID = "Button2" Type = "Button" Value = "Cancel" Onclick = "Cancelasyncpostback ();"   />
</ Progresstemplate >
</ ASP: updateprogress >

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

 

References:

Msdn: http://msdn.microsoft.com/en-us/library/bb386518.aspx

 

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.