Recently I was reading about the UpdatePanel and I came across a property called ChildrenAsTriggers. As you all know UpdatePanels has 2 types of triggers
Both of these triggers cause a postback to server depending on the trigger type we use. But there is another property called ChildrenasTriggers. This property tells you whether child controls needs to be update when a post back happens. By default this property is set to True i.e always update the child controls. If you are wondering why we need to set this property to false , consider a scenario where we have update panel inside an update panel (Nested Update Panel) like the below.
<form id=”form1″ runat=”server”>
<div><asp:ScriptManager ID=”ScriptManager1″ runat=”server”></asp:ScriptManager>
<asp:UpdatePanel ID=”upOuterPanel” runat=”server” ChildrenAsTriggers=”false” UpdateMode=”Conditional”><ContentTemplate>
<div>Outer Last Updated = <%=DateTime.Now.ToLongTimeString()%> </div>
<div><asp:Button ID=”btnOuter” runat=”server” Text=”Outer Update” /> </div>
<asp:UpdatePanel runat=”server” ID=”upInnerPanel” >
<ContentTemplate> <div> Inner Last Updated = <%=DateTime.Now.ToLongTimeString()%></div>
<div> <asp:Button ID=”btnInnerUpdate” runat=”server” Text=”Inner Update” />
In the above code I have a button control in each of the update panels and notice the ChildrenasTriggers set to false for outer update panel. So this means when we click the Outer Update button the text for Outer Last Updated field is not updated. Also ChildrenasTriggers can be set to False only when the UpdateMode is set to Conditional. Attempting to do so without this condition results in an InvalidOperationException being thrown by the ScriptManager during the page’s PreRender event. Now if we click any button ( Inner or Outer ) the text for Outer Label will not change because we are telling the ScriptManager not to update the contents of the Outer Text whenever any async post back happens. But the inner label time always changes with any button click because upInnerPanel is a child control of upOuterPanel. If we set UpdateMode=”Conditional”
for upInnerPanel then if we click btnInnerUpdate then only upInnerPanel will be updated. Hope this helps..