I've read tons of literature and consulted my pro c#/ASP.NET books.
I have this code in my user control.
- public event EventHandler BubbleClick;
-
protected void OnBubbleClick(EventArgs e)
-
{
-
if (BubbleClick != null)
-
{
-
BubbleClick(this, e);
-
}
-
}
When I load the control dynamically I want to add a new EventHandler to the user control.
But BubbleClick is not a definition of UserControl so how do I assign an EventHandler to it?
Totally stumped. Here's the bit that's not working.
- while (i < compLength)
-
{
-
string compPath = "_components/" + compType[i].Type + ".ascx";
-
UserControl compControl = (UserControl)Page.LoadControl(compPath);
-
compControl.ID = Convert.ToString(compType[i].CompId);
-
//PlaceHolder plcName = (PlaceHolder)Master.FindControl("MainContent").FindControl("PlaceHolderName" + compType[i].PlaceHolder.ToString()); //Find all PlaceHolders - names PlaceHolderName0, PlaceHolderName1...
-
PlaceHolder plcName = (PlaceHolder)findControl("PlaceHolderName" + compType[i].PlaceHolder.ToString(), Master);
-
plcName.Controls.Add(compControl);
-
if (compControl.ID == "1")
-
{
-
-
compControl.BubbleClick += new EventHandler(BtnCloseEditMode_Click);
-
}
-
i++;
-
}