views:

34

answers:

1

Here is my code:

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server">
            <ContentTemplate>
                <asp:Button ID="Button1" runat="server" Text="Click1" OnClick="Button1_Click" />
                <br />
                <br />
                Last refresh
                <%=DateTime.Now.ToString() %>
                <br />
                <br />
                <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
                    <ContentTemplate>
                        <asp:Button ID="Button2" runat="server" Text="Click2" OnClick="Button2_Click" />
                        <br />
                        <br />
                        Last refresh
                        <%=DateTime.Now.ToString() %>
                        <br />
                        <br />
                    </ContentTemplate>
                     <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
            </Triggers>
                </asp:UpdatePanel>
            </ContentTemplate>
             <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    </form>
</body>

Im using two update panels here, when i click "Button2" then "UpdatePanel2" was refreshed, if i click "Button1" then both update panel were refreshed, but my need is if i click "Button1" then "UpdatePanel1" have to be refreshed.

Thanks.

+3  A: 

This behavior is by design. Because your UpdatePanel2 is nested inside of UpdatePanel1, when you refresh the contents of UpdatePanel1, this includes the child UpdatePanel.

If you want UpdatePanel2 to act separately from UpdatePanel1, you're going to have to take it out of UpdatePanel1 and make it a sibling, rather than a child.

womp
Without taking "UpdatePanel2" outside, can we set any properties to avoid the refresh of "UpdatePanel2".
ram
No. As I said, when you refresh #1, all it's contents are refreshed. This happens to include panel #2. If you don't want this to happen, you need to restructure your panels.
womp