Hello friends
I'm trying to perform event bubble on a user control from the example on
http://odetocode.com/Articles/94.aspx
but this example doesn't work... when I run the code it says BubbleControl
does not exist which makes sense as nothing was assigned to BubbleControl.. .
I'm just curious if I should assign because I did try assigning
BubbleControl with a new instance but still it did not assign the event to
BubbleControl.B ubbleClick on the user control side.
Just wondering if anyone know how to do this.
Thanks
Tom
public class WebForm1 : System.Web.UI.P age
{
protected WebUserControl1 BubbleControl;
private void Page_Load(objec t sender, System.EventArg s e)
{
Response.Write( "WebForm1 :: Page_Load <BR>");
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
BubbleControl.B ubbleClick += new EventHandler(We bForm1_BubbleCl ick);
}
#endregion
private void WebForm1_Bubble Click(object sender, EventArgs e)
{
Response.Write( "WebForm1 :: WebForm1_Bubble Click from " +
sender.GetType( ).ToString() + "<BR>");
}
}####### control public class WebUserControl1 : System.Web.UI.U serControl
{
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Pane l Panel1;
private void Page_Load(objec t sender, System.EventArg s e)
{
Response.Write( "WebUserControl 1 :: Page_Load <BR>");
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Write( "WebUserControl 1 :: Begin Button1_Click <BR>");
OnBubbleClick(e );
Response.Write( "WebUserControl 1 :: End Button1_Click <BR>");
}
public event EventHandler BubbleClick;
protected void OnBubbleClick(E ventArgs e)
{
if(BubbleClick != null)
{
BubbleClick(thi s, e);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{
this.Button1.Cl ick += new System.EventHan dler(this.Butto n1_Click);
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}