UpdateRegion (AjaxControlFramework.UpdateRegion)


The UpdateRegion is one of the out-of-the-box Ajaxified UI controls that is packaged with the AJAX Control Framework. It is a non-visual component that allows developers to turn PostBack driven, hardly dynamic and slow sections of markup in quick, lean and delicious sections. Simply wrap a portion of your markup with the start and end tags of an UpdateRegion control and POOF all PostBack events within that region will be intercepted and handled within an AJAX call. That region's markup will automatically be replaced with updated markup returned by the AJAX call.


The UpdateRegion control is the equivalent of the UpdatePanel control included in ASP.NET AJAX. I know what you're thinking. "Oh great...ANOTHER UpdatePanel knock off." It's true that this particular control has been done before, and numerous times. But the AJAX Control Framework's UpdateRegion is different though. There are a number of aspects of how the UpdateRegion operates in the context of the AJAX Control Framework that make it extraordinarily relevant.

Here's what makes the AJAX Control Framework's UpdateRegion better than all the others:
  • ViewState is tracked for the contents of the UpdateRegion only. This means that the overhead of ViewState processing is dramatically reduced to the bare essentials. (Unfortunately though, the ViewState of parent controls is not tracked during the UpdateRegion's AJAX calls, so referencing ViewState-bound parent controls within the UpdateRegion is not supported. But, you should be avoiding such dependencies anyway.)
  • The UpdateRegion focuses on loading and re-rendering just its contents, and avoids all of the parent Page's lifecycle events after Init. Only the UpdateRegion has all of its Page Lifecycle events invoked. And still, the UpdateRegion operates exactly as it would if a normal PostBack were being performed.
  • Because the UpdateRegion is processed by the AJAX Control Framework's CallbackStrategy, only data relevant to the UpdateRegion's content is passed to and from the server (minus the encoded ViewState, or course).



<ajaxControl:UpdateRegion runat="server">
    <asp:Button runat="server" id="btnClick" Text="Don't click me there!" OnClick="btnClick_Click" />
    <asp:Label runat="server" ID="lblClickResult" Visible="false"></asp:Label>


protected void btnClick_Click(object sender, EventArgs args)
    btnClick.Visible = false;
    lblClickResult.Text = "KAPOW!!!";
    lblClickResult.Visible = true;

Last edited May 2, 2010 at 3:24 AM by peanutbutterlou, version 2


No comments yet.