views:

378

answers:

1

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.)

+2  A: 

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.

womp
That explains that issue. The parent's contents are not changing, only the child's. The parent's OnLoad method is wrapped in an if(!IsPostBack) { ... } so that no damage is done. It still seems odd that the parent's OnLoad would be called but not the child's or the button's Click function.
pschorf
Yeah it is odd and it's a constant source of confusion and error. Glad it helped you though. If it helped to answer your problem, you should upvote the post and perhaps accept the post as the answer if you are satisfied that your issue is resolved.
womp