UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

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 !!!

Print | posted on Sunday, August 12, 2007 7:52 PM

Comments on this post

# re: UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

Requesting Gravatar...
Hi Harish,

I was a bit disappointed that your "internals" session does not talk about HOW it renders ONLY the required HTML [HTML inside the UpdatePanel triggering the Async Postback].

I read [in the ONLY post I could find that talked about this] that there're TWO HtmlTextWriters as ASP.Net needs to Render ALL HTML in order for it to compute EventValidationhash.

http://blogs.interknowlogy.com/joelrumerman/archive/2006/04/23/1933.aspx

I used reflector to search and came up dry on Microsoft.Web.UI.DummyHtmlTextWriter...

Help?

Regards, Vyas
Left by Vyas Bharghava on Sep 26, 2007 1:11 AM

# re: UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

Requesting Gravatar...
I had a query regarding multiple update panels.
I have a user control which contains one update panel.This user control contains a hidden textbox .
I am updating the updatepanels on basis of a timer control in javascripts which raises a postback.

I have placed two instances of this user control in another page say for eg. CIndexPage.aspx.
Now the Script manager is also placed in the same page ie CIndexPage.aspx.

Will the two updatepanels wrk independently.
I have tried but the hidden values are not getting updated for the same updatepanel and getting interchanged.

Please if someone cld help me with this.

Regards,
Shweta
Left by Shweta on Oct 31, 2007 10:36 PM

# re: UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

Requesting Gravatar...
@Shweta:

Did you try setting UpdateMode="conditional" for the update panel?

I know this post is outdated, but might help someone.
Left by Sachin on Dec 21, 2008 6:41 PM

# re: UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

Requesting Gravatar...
Helping me a lot to get to grip with the internals of the update panel!
Left by worldcup on Mar 31, 2010 7:48 AM

# re: UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

Requesting Gravatar...

The cellphone is the world’s most ubiquitous computer. The four billion cellphones in use around the globe cell phone provide access to the Web mobile phonesand are being used cell phones to Sciphone i9unlocked cell phonesnavigate the real world. And as cellphones change how we live phones.
Left by Ellah on May 13, 2010 1:15 AM

# re: UpdatePanel Internals - Part II - My Session at Tech Mela Contd.,

Requesting Gravatar...



This is good only if you limited number of scripts
Left by meksika biberi zayiflama hapi on Jun 01, 2010 12:22 AM

Your comment:

 (will show your gravatar)