I have ASP.NET Web Application that contains MasterPage, ASPX Page where I load User Controls dynamically into UpdatePanel containing PlaceHolder based on menu selection. This works fine. The problem is that no events in my User Controls work.. I have different scenarios:
- DropDownList, where selected value should load different UserControls
- LinkButton, where Click event should load different UserControl into the PlaceHolder (on the parent page).
I have spent 3 days on this now and tried several things for this.... Registered events, used Interface among other things....
but so far nothing has worked :( ..thankful for any help I can get.
Yes, i have tried Page_PreInit event on the User Control as well. The only thing that fires when I click my LinkButton (or DropDownList) in my user control is the Page_Load event on the parent page..and then the PlaceHolder containing the user control (i am clicking) has Contol.Count = null Here is some code
//Page_Load on parent page:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadDefaultControl(ctrlPlaceHolder, Base_Path + "_Services.ascx");
}
}
//Page_Load in my Usercontrol
protected void Page_Load(object sender, EventArgs e)
{
btJoomlaManagement.Click += btJoomlaManagement_Click;
}
The PlaceHolder on the parent page is inside a UpdatePanel >> ContentTemplate.
<asp:UpdatePanel ID="pnlControlContainer" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="ctrlPlaceHolder" runat="server" EnableViewState="False" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="menuServices" />
</Triggers>
</asp:UpdatePanel>
The behavior is following..when I load my USerControl Page_Load with the Click event runs..when I click my Linkbutton in my usercontrol, Page_Load on the parent page runs but not my Click method in my usercontrol. The usercontrol (that I just clicked my Linkbutton on) disappears.
So my event (click) does not fire... hope you understand a little better.