Gets or sets a value that indicates when an UpdatePanel control's content is updated.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
When an UpdatePanel control is not inside another UpdatePanel control, the panel is updated according to the settings of the and ChildrenAsTriggers properties, together with the collection of triggers. When an UpdatePanel control is inside another UpdatePanel control, the child panel is automatically updated when the parent panel is updated.
The content of an UpdatePanel control is updated in the following circumstances:
If the 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 property is set to Conditional, and one of the following conditions occurs:
The postback is caused by a control that is defined as a trigger by using the Triggers property of the UpdatePanel control. In this scenario, the control explicitly triggers an update of the panel content. The control can be either inside or outside the UpdatePanel control that defines the trigger.
The ChildrenAsTriggers property is set to true and a child control of the UpdatePanel control causes a postback. A child control of a nested UpdatePanel control does not cause an update to the outer UpdatePanel control unless it is explicitly defined as a trigger.
The following example shows how to use the property. The example declares two UpdatePanel controls. In the first panel, the property is set to Conditional. In the second panel, is set to Always. A button outside both panels is registered as an asynchronous postback control by calling the RegisterAsyncPostBackControl method of the ScriptManager control. In the button's Click event handler, the Update method of the first panel is called if more than five seconds have elapsed since its last update. In this scenario, the panel’s content is updated only if the last panel refresh was more than five seconds ago. The content of the second panel is always updated.
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Property LastUpdate() As DateTime Get If Not ViewState("LastUpdate") Is Nothing Then Return ViewState("LastUpdate") Else : Return DateTime.Now() End If End Get Set(ByVal Value As DateTime) ViewState("LastUpdate") = Value End Set End Property Protected Sub Button1_Click(ByVal Sender As Object, ByVal E As EventArgs) If (LastUpdate.AddSeconds(5.0) < DateTime.Now) Then UpdatePanel1.Update() LastUpdate = DateTime.Now End If End Sub Protected Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) ScriptManager1.RegisterAsyncPostBackControl(Button1) If Not IsPostBack Then LastUpdate = DateTime.Now End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>UpdatePanelUpdateMode Example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:Panel ID="Panel1" GroupingText="UpdatePanel1" runat="server"> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <p> The content in this UpdatePanel only refreshes if five or more seconds have passed since the last refresh and the button in UpdatePanel2 was clicked. The time is checked server-side and the UpdatePanel.Update() method is called. Last updated: <strong> <%= LastUpdate.ToString() %> </strong> </p> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <asp:Panel ID="Panel2" GroupingText="UpdatePanel2" runat="server"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <p> This UpdatePanel always refreshes if the button is clicked. Last updated: <strong> <%= DateTime.Now.ToString() %> </strong> </p> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <asp:Button ID="Button1" Text="Button1" runat="server" OnClick="Button1_Click" /> </div> </form> </body> </html>
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.