Homam
Homam

Reputation: 23841

When UpdatePanel make PostBack to another one

I have a complicated case, so I can't post it.

I have two UpdatePanels with two UserControls inside them, like the following:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <A:u1 ID="u1" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <A:u2 ID="u2" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>

In this sample, the PostBack in u1 doesn't effect on u2. but in my code the PostBack in the first UserControl made a PostBack in the second.

What are the expected reasons ??

Thanks for the help.

Upvotes: 1

Views: 440

Answers (1)

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 262939

This is by design: when a partial postback occurs, the whole page is rendered again even if only part of the resulting markup is sent to the client. Thus, both your user controls go through their lifecycles again, even if only u1 is updated.

If you want to detect that case, you can use the IsInAsyncPostBack property:

protected void Page_Load(object sender, EventArgs e)
{
    if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) {
        // This is a partial postback.
    }
}

Upvotes: 1

Related Questions