Bubble Event

S

shapper

Hello,

I have the following:

Parent > Child > Button

Parent is a custom control. Child is another custom control added to
Parent.
Button is an ASP.NET button added to Child control.

Parent has an event named Submitted. I want to fire this event when
the Button is clicked.
My first approach can be described in the following order:

1. Catch Button Click event in Child
2. Fire a ButtonWasClicked event in Child
3. Catch ButtonWasClicked event in Parent
4. Fire Submitted event in Parent

Now I got to know that there is something called BubbleEvent which
fires an event up to the control hierarchy.

I have the following, inside my Child class:

' MyButton_Click
Private Sub MyButton_Click(ByVal sender As Object, ByVal e As
EventArgs) Handles MyButton.Click

RaiseBubbleEvent(MyButton, e)

End Sub

I am now sure if this is right and how can I catch the event in my
Parent class.

Could someone please help me out?

Thanks,
Miguel
 
P

Patrice

Basically the scheme in your class child would be something such as :
Event Submit()

Private Sub button_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles button.Click

RaiseEvent Submit()

End Sub



Then when you use to child class you can react to the submit event. If used
in a parent control you can then use the same scheme to expose the submit
event to consumers.

Finally when you use the Parent class you just have to react to its submit
event wihtout ahving anyhting to know about inner controls details...
 
B

bruce barker

in the parent you override OnBubbleEvent to catch the event. From this
you raise whatever events you want. Normally to identify what type of
event was bubbled up, a custom EventArgs would be used in the
RaiseBubbleEvent.

-- bruce (sqlwork.com)
 

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

Similar Threads

Event 2
Bubble Event 0
Event 0
Event 1
Fire Event 1
Button Click 1
raise a bubble event. 1
Stopping a bubble event 1

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top