Given a simple example with two nested Update-Panels. They are nested, and each one has a label which is filled with the current time in the code behind. I don't understand why the ChildrenAsTriggers="true"
- Property on the outer UpdatePanel has no effect? When I hit the 'Update Nested Panel' - button, the time in the parent UpdatePanel is not updated. But as far as I understand the property, it should be:
<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>
Thx for any tipps! sl3dg3
p.s.: code behind:
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();
}
When the ChildrenAsTriggers property is set to true and any child control of the UpdatePanel control causes a postback. Child controls of nested UpdatePanel controls do not cause an update to the outer UpdatePanel control unless they are explicitly defined as triggers for the parent panel. http://forums.asp.net/t/1422425.aspx/1
and this should be like...
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonUpdate" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ButtonUpdateNestedPanel" EventName="Click" />
</Triggers>
......
......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With