var prm = Sys.WebForms.PageRequestManager.getInstance();
Before calling the function you have to hook up to the PageRequestManager instance for the current page (the PageRequestManager object is responsible for managing partial page updates for UpdatePanel controls on the page). Calling Sys.WebForms.PageRequestManager.getInstance() gets you the current instance. PageRequestManager is used by CancelAsyncPostBack() to [a] check if an AsyncPostBack is currently in progress (when the cancel request is received) and [b] abort the AsyncPostBack by calling the abortPostback() method.
If u use any session variables on the aspx page, on the start MS AJAX wont even generate an Async call from client [all are sync calls !] so the call to this method prm.get_isInAsyncPostBack() always returns false,
over which u cannot cancel even this sync call either until the currnet call completes !
here is my post :
Hi Gopi. That's not the behaviour I'm seeing - it seems to work fine on my page. I tested on the tutorial page you point to and I do see the behaviour. But on my page I have a thread sleep for 10s and I can still cancel the request and submit another - at least it gives the illusion of working. As Steve points out in his reply to your forum posting, there's no way to cancel the server reqeust so a subsequent request has to wait for the initial one to complete. And I definitely see prm.get_isInAsyncPostBack() = true on my initial request. My page behaves exaclty as I would expect so I'm not sure what the difference is.
Mike, just add a [or on the tutorial sample]
Session["Test"] = "123"; on your page_load and try using that
Session in your call back method, along with a thread.sleep for 30 sec.
Now cancel the async postback using cancel update, it wont cancel the update until the full 10 sec is completed on server and the response returns back to client !
The main point is when u use any kind of Session Variables on your server code, u cannot cancel the async request !