Asp – Why would a child control of a child update panel update both parent and child if each is set to conditional

ajaxasp.netupdatepanel

We have a structure which has 3 main UpdatePanels, each of which has several nested UpdatePanels (but only one level of nesting.) All of the panels are set to conditional with ChildrenAsTriggers set to false, so it looks roughly like this:

<asp:UpdatePanel ChildrenAsTriggers="false" OnLoad="Update_OnLoad" 
    ID="updateCol2" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
        <asp:UpdatePanel ChildrenAsTriggers="false" UpdateMode="Conditional" 
            ID="updateFeed" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
            </Triggers>
            <ContentTemplate>
                <asp:Button OnClick="function" ID="btnSubmit" runat="server" />
            <ContentTemplate>
         </asp:UpdatePanel>
    </ContentTemplate>
</asp:UpdatePanel>

I would expect that the OnLoad function of the parent update panel would never run except on the actual page load, and that the button's OnClick function would be executed on every click, updating the child updatepanel. However, the parent UpdatePanel IS updated on every click of the button, and the child update panel only fires afterward (as a result of the parent updatepanel's update.)

Best Answer

Is the parent update panel actually updating, i.e. the contents are changing?

I would expect that the OnLoad function of the parent update panel would never run except on the actual page load

This is a false, but unfortunately common assumption. Remember that even though it's an asynchronous postback, the entire page and control lifecycle is executed for every control, including Load and Init. It's just like you were requesting the page normally.

The difference is that it's only the UpdatePanel's region of the page that would be updated, not the entire UI.

For more on how UpdatePanels work there is a great article on ASP.Net Ajax documentation site.

Related Topic