14.3. The UpdatePanel Control

The UpdatePanel control, in conjunction with the ScriptManager, defines areas within the web page to be partially updated without refreshing the entire page. These areas can be updated independently of one another and are usually triggered to update the content contained in them. An UpdatePanel can be added to the page declaratively with tags or programmatically.

14.3.1. Adding the UpdatePanel to the Page

Adding an UpdatePanel is a simple process. The first step is to add a ScriptManager control to the page.

<asp:ScriptManager ID="ScriptManager1" runat="server" />

The next step is to decide how the UpdatePanel behaves. The UpdatePanel class inherits the System.Web.UI.Control class, so all the attributes exposed by the parent are exposed by the child class. The most important attributes, however, are specific to the UpdatePanel class. They are:

  • ChildrenAsTriggers: A Boolean value that indicates whether or not the UpdatePanel should be updated when immediate child controls cause a postback. A postback is the process of sending and receiving data from the server. The default value for this attribute is true. Note that children of a nested UpdatePanel do not cause an update of the parent UpdatePanel.

  • RenderMode: Indicates how the panel is rendered. If set to "Block" (the default), the ASP.NET engine renders the UpdatePanel as a <div/> element. If "Inline", the panel is rendered as a <span/> element.

  • UpdateMode: Determines how the panel's contents are updated. ...

Get Professional Ajax, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.