This article is in continuation with my earlier article on Update Panel Internals - TechMela Session 2 - Deep Dive: ASP.NET AJAX so you may want to check it before reading this, in case you havent read it already.

So, we left at the place where we were examining what is the HTML output when using a simple ScriptManager tag in your page, Adding an UpdatePanel, adding multiple UpdatePanels, UpdatePanels with Trigger etc.,  We were particularly drilling into the HTML Markup that is generated when adding an UpdatePanel and subsequently multiple UpdatePanels, Triggers etc., to your page, the array they get appended to, in the markup.  There is one more pending Array which might interest you, on what goes into it.  It would contain the normal Postback controls when declared as a trigger for the UpdatePanel.

When you declare an UpdatePanel with a Trigger, you can define a trigger to be either Async Postback or a normal Postback.  A normal PostBack would result in the whole page refreshing along with the Update Panel area.  Theoretically this sounds stupid since you can as well  put a normal button anywhere in the page and call the refresh.  However, there are scenarios where you would want a Trigger arising out of UpdatePanel to refresh the page and these trigger control IDs go into the third Array as seen in the following markup snippet (currently it is a blank array in this example).  The final thing '90' is the timeout which specifies when it will timeout before it can complete the async postback and here it is 90 seconds. 

Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1','tUpdatePanel2','tUpdatePanel3'], ['Button4'], [], 90);

A word of note though is that, updateControls method is internal and it might change anytime with a next release / Service Pack so dont rely on this markup specifically.

What we originally intended was, to find out, how the UpdatePanel works :)  So lets proceed in that direction.

Like mentioned in the Part I, the Update Panel works in conjunction with the Script Manager defined in the page and calls the updateControls method which internally calls the _onFormSubmitCompleted method which is part of MicrosoftAjaxWebform.js file located in the Microsoft AJAX Library that is installed.

The sequence of Page Processing that happens for an AJAX Enabled Page is as follows:-

  • initializeRequest
  • beginRequest
  • pageLoading
  • pageLoaded
  • endRequest

All of the above are members of the PageRequestManager class which is the key class in Asynchronous postbacks.  You can imagine the PageRequestManager class as an equivalent to Page Class in a normal ASP.NET Web Page.  However, PageRequest Manager class doesnt replace the normal Page Class methods like Page_Init, Page_Load etc., The only difference in an asynchronous postback is that, the Page_Render method renders back only the modified HTML markup and it doesnt re-render the whole page as in the case of a normal ASP.NET Webform Pafe Life cycle.

So, if you want to handle an Async Postback execution and abort it, the class to take instance of is the PageRequestManager class.

We will explore more on PageRequestManager class and how to use its instance to work with the different methods in the next article.

Cheers !!!