event bubble


T

Tom Gao

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.BubbleClick on the user control side.

Just wondering if anyone know how to do this.

Thanks
Tom

public class WebForm1 : System.Web.UI.Page
{
protected WebUserControl1 BubbleControl;

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("WebForm1 :: Page_Load <BR>");
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
BubbleControl.BubbleClick += new EventHandler(WebForm1_BubbleClick);
}
#endregion

private void WebForm1_BubbleClick(object sender, EventArgs e)
{
Response.Write("WebForm1 :: WebForm1_BubbleClick from " +
sender.GetType().ToString() + "<BR>");
}
}####### control public class WebUserControl1 : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Panel Panel1;

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("WebUserControl1 :: Page_Load <BR>");
}

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("WebUserControl1 :: Begin Button1_Click <BR>");
OnBubbleClick(e);
Response.Write("WebUserControl1 :: End Button1_Click <BR>");
}

public event EventHandler BubbleClick;

protected void OnBubbleClick(EventArgs e)
{
if(BubbleClick != null)
{
BubbleClick(this, e);
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

}
 
Ad

Advertisements

A

Anders Borum

Please post asp.net related questions to
microsoft.public.dotnet.framework.aspnet
 
T

Tom Gao

errr... why ?

it would take me 1 week to get a response there ?

whats the difference anyway ? this is C# and I'm using C#

Thanks
Tom
 
T

Tom Gao

if you got the time why don't you answer my question ? does it matter where
I post ?

I think you're wasting my post thread

so please go annoy someone else
 
A

Anders Borum

Hello!
does it matter where I post ?

No. Microsoft obviously created the different newsgroups just for fun with
no real intention of grouping related technologies (phun intended).
I think you're wasting my post thread

so please go annoy someone else

I would be careful about talking to other people like that. Especially when
you're in a position asking for help.
 
Ad

Advertisements

J

Jon Skeet [C# MVP]

Tom Gao said:
errr... why ?

it would take me 1 week to get a response there ?

I'm sure it won't if you make a good request (eg with full sample
code).
whats the difference anyway ? this is C# and I'm using C#

Just because you're using C# doesn't mean that it's a question *about*
C#.

This is twice in two days that you've been rude in a response. Are you
always like this with people who are trying to help you? If you keep
going like this, you're unlikely to get *any* help after a while. Why
would anyone want to respond to you if you're just going to be rude
back?
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top