I have UpdatePanel with button.
<asp:UpdatePanel runat="server" ID="upOuter" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnNestInnerPanel" runat="server"
OnClick="btnNestInnerPanelClick" Text="Nest Update Panel" />
</ContentTemplate>
</asp:UpdatePanel>
I want to nest inner updatepanel with other button in outer updatepanel by click that button. And I want to update inner updatepanel by click new button. Page has such behind code:
public partial class _Default : Page
{
private Button btnInner;
protected void Page_Load(object sender, EventArgs e)
{
btnInner = new Button { Text = "Click Me", ID = "MyId" };
btnInner.Click += btnInnerClick;
}
protected void btnNestInnerPanelClick(object sender, EventArgs e)
{
UpdatePanel upInner = new UpdatePanel();
upInner.UpdateMode = UpdatePanelUpdateMode.Conditional;
upInner.ContentTemplateContainer.Controls.Add(btnInner);
upOuter.ChildrenAsTriggers = false;
upOuter.ContentTemplateContainer.Controls.Add(upInner);
}
private void btnInnerClick(object sender, EventArgs e)
{
Button btn = (Button)sender;
}
}
When I click first button, it causes update of panel and inner panel appears. That's correct. But if I click newly created button in inner panel, btnInnerClick handler is not raised. Does anybody know what's problem?
If I nest dynamically inner updatepanel in simple placeholder (not in outer updatepanel), btnInnerClick handler is raised correctly. I have no idea...