Recently a new requirement came for cancel an async operation. Being aware of the abortPostBack method the PageRequestManager, I figured that it would be pretty simple to implement this feature. I added a ‘Cancel’ button to my progress indicator and wired the onclick handler to invoke the abortPostBack method.
Clicking cancel did abort the async postback however, because the OnUpdated animation only runs when the UpdatePanel is updated my indicator was never being hidden and it was appearing as if the application was hanging. My approach to solving this was to look-up the animation component and invoke the animation myself. like this:
function abort(){
var prm = Sys.WebForms.PageRequestManager.getInstance();
if(prm get_isInAsyncPostBack()){
// abort the postback
prm abortPostBack();
// get the reference to the animation for the gridview
var animation = $find('animation');
// simulate stopping by replaying the animation
animation._postBackPending = false;
animation.get_OnUpdatingBehavior().quit();
animation.get_OnUpdatedBehavior().play();
}
}
SOURCE
(more...)

