嵌套的UpdatePanel:为什么ChildrenAsTriggers没有效果?

sl3*_*dg3 5 c# asp.net ajax updatepanel nested

给出一个带有两个嵌套Update-Panel的简单示例.它们是嵌套的,每个都有一个标签,后面的代码中填充了当前时间.我不明白为什么ChildrenAsTriggers="true"- 外部UpdatePanel上的属性没有效果?当我点击"更新嵌套面板"按钮时,父UpdatePanel中的时间不会更新.但据我了解该财产,它应该是:

<asp:ScriptManager ID="ScriptManager1" runat="server" 
    onasyncpostbackerror="ScriptManager1_AsyncPostBackError">
</asp:ScriptManager>

<asp:Button ID="ButtonUpdate" runat="server" Text="Update Panel 1"
    style="margin-top: 15px" onclick="ButtonUpdate_Click" />
<asp:Button ID="ButtonUpdateNestedPanel" runat="server" Text="Update Nested Panel"
    style="margin-top: 15px" onclick="ButtonUpdateNestedPanel_Click" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ButtonUpdate" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" />

        <asp:UpdatePanel ID="UpdatePanelNested" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ButtonUpdateNestedPanel" EventName="Click" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="LabelNested" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>

    </ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)

任何tipps的Thx!sl3dg3

ps:代码背后:

protected void ButtonUpdate_Click(object sender, EventArgs e)
{
    LabelNested.Text = DateTime.Now.ToString();
    Label1.Text = DateTime.Now.ToString();
}
protected void ButtonUpdateNestedPanel_Click(object sender, EventArgs e)
{
    LabelNested.Text = DateTime.Now.ToString();
    Label1.Text = DateTime.Now.ToString();
}
Run Code Online (Sandbox Code Playgroud)

Muh*_*tar 1

当 ChildrenAsTriggers 属性设置为 true 并且 UpdatePanel 控件的任何子控件都会导致回发时。嵌套 UpdatePanel 控件的子控件不会导致外部 UpdatePanel 控件的更新,除非它们被显式定义为父面板的触发器。 http://forums.asp.net/t/1422425.aspx/1

这应该是这样的...

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ButtonUpdate" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="ButtonUpdateNestedPanel" EventName="Click" />
        </Triggers>
......   
......
Run Code Online (Sandbox Code Playgroud)