wawang
9/27/2006 2:25:00 AM
Hi Marc,
For the built-in web controls, three of them are bubbling event by default:
Button, ImageButton, and LinkButton.
If you use Reflector to run command "Analyzer" on Control.RaiseBubbleEvent,
you will see these:
* Button.OnCommand
* ImageButton.OnCommand
* LinkButton.OnCommand
OnCommand will be used by RaisePostBackEvents which means it will gets
called when it's clicked and posted back.
* DataGridItem.OnBubbleEvent
* DataListItem.OnBubbleEvent
* DetailsViewRow.OnBubbleEvent
* FormViewRow.OnBubbleEvent
* GridViewRow.OnBubbleEvent
* Menu.OnBubbleEvent
* MenuItemTemplateContainer.OnBubbleEvent
* RepeaterItem.OnBubbleEvent
These are actually good examples of how to bubbling up the events when you
received bubbled event from your templated contents. Use RepeaterItem for
example, when you put a control which is calling RaiseBubbleEvent inside
the template, what you need to do is to override OnBubbleEvent and bubble
them up again. The bubbled event from RepeaterItem will be handled in
Repeater's overridden OnBubbleEvent:
Protected Overrides Function OnBubbleEvent(ByVal sender As Object, ByVal e
As EventArgs) As Boolean
Dim flag1 As Boolean = False
If TypeOf e Is RepeaterCommandEventArgs Then
Me.OnItemCommand(DirectCast(e, RepeaterCommandEventArgs))
flag1 = True
End If
Return flag1
End Function
I hope this helps you understand how the event bubbling works. For your
last question, other than the Button, LinkButton, ImageButton controls, all
other controls are not bubbling event up by default.
I understand that your initial requirement is to handle controls' events
which are placed inside your control's templates. Besides using event
bubbling, you can use FindControl to find the controls inside the template
using their ID, and hook up its event handler dynamically.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.