I am working on an asp.net/C# web application,
In the main page:
I have a place Holder inside of an update panel
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
</asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
I use this to dynamicaly load a web user control when I click on “LinkButton1”
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="Link1_Click">Load</asp:LinkButton></li>
in the code behind:
protected void Link1_Click(object sender, EventArgs e)
{
PlaceHolder1.Controls.Clear();
(MyControl) CC = (MyControl)LoadControl("Controls/MyControl.ascx");
PlaceHolder1.Controls.Add(CC);
}
In the control I am loading I placed an update panel which is triggered by a check box in the control.
In MyControl:
<asp:UpdatePanel ID="MapRefresh" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CheckBox1" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
//Here I place the things I want to update
</ContentTemplate>
</asp:UpdatePanel>
The checkbox is declared outside the update panel
<asp:CheckBox ID="CheckBox1" Checked="true" Text="View" runat="server" AutoPostBack="True" oncheckedchanged="CheckBox1_CheckedChanged" />
in the code behind:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
//Do the update on the controls that are in the update panel
}
The problem:
From the main page, when I click on the LinkButton1 The control load correctly and everything is fine.
But When I click on the checkbox of the control, it does not update the inner update panel like i want it to. The control just disappear from the main page.
Any help is greatly appreciated.
Thanks in advance and I hope I was clear
You need to create the user control in the page onload event and make it hidden. Recommend you create the control there and use the link button to make it visible and set other properties.