Update Panel control

First step one should take to understand UpdatePanel – what it is and what it can do…

MSDN – UpdatePanel Class
MSDN – UpdatePanel Control Overview

There’s a lot of information. Some are easy, some are a bit more trickier. Extracting some below…

UpdatePanel’s update process is coordinated by the ScriptManager server control and the client PageRequestManager class. An asynchronous postback behaves like a regular postback in that the resulting server page executes the complete page and control life cycle. However, with an asynchronous postback, page updates are limited to the regions of the page that are enclosed in UpdatePenel controls and that are marked to be updated.

Add content to UpdatePanel

  • Declaratively – just include between <ContentTemplate></ContentTemplate>
  • Programmatically – use ContentTemplateContainer property

By default, any postback control inside an UpdatePanel control causes an asynchronous postback and refreshes the panel’s content, or you can specify a trigger. A trigger is a binding that specifies which postback control and event cause a panel to update. Controls inside an UpdatePanel control that causes a postback are automatically configured as triggers for the UpdatePanel control. To disable Automatic Triggers, set ChildrenAsTriggers to false and UpdateMode to Conditional. To specify triggers declaratively, register a control by using the RegisterAsyncPostBackControl method of the ScriptManager control. Controls that are programmatically identified as triggers must be registered every time that a postback occurs. It’s recommanded to be registered in Page_Load.

Example: ScriptManager1.RegisterAsyncPostBackControl(SurveyDataList);

How UpdatePanel Controls Are Refreshed:

  • If the UpdateMode property is set to Always, the UpdatePanel control’s content is updated on every postback that originates from anywhere on the page. This includes asynchronous postbacks from controls that are inside other UpdatePanel controls, and postbacks from controls that are not inside UpdatePanel controls.
  • If the UpdateMode property is set to Conditional, the UpdatePanel control’s content is updated when one of the following is true:
    • When the postback is caused by a trigger for that UpdatePanel control
    • When you explicitly call the UpdatePanel control’s Update method
    • When the UpdatePanel control is nested inside anotehr UpdatePanel control and the parent panel is updated
    • When the ChildrenAsTriggers property is set to true and any child control of the UpdatePanel control causes a postback. Child controls of nested UpdatePanel controls do not cause an update to the outer UpdatePanel control unless they are explicitly defined as triggers for the parent panel.

Nested UpdatePanel Controls work like this:

  • Parent UpdatePanel refreshes all the contents including Child UpdatePanel