What is event bubbling in .NET?- The passing of the control from the child to the parent is called as bubbling.
- Controls like DataGrid, Datalist, Repeater, etc can have child controls like Listbox, etc inside them.
- An event generated is passed on to the parent as an ItemCommand.
- The ASP.NET page framework provides a technique called event bubbling that allows a child control to propagate events up its containment hierarchy.
- Event bubbling enables events to be raised from a more convenient location in the controls hierarchy and allows event handlers to be attached to the original control as well as to the control that exposes the bubbled event.
- It is used by the data-bound controls (Repeater, DataList, and DataGrid) to expose command events raised by child controls (within item templates) as top-level events.
- While ASP.NET server controls in the .NET Framework use event bubbling for command events (events whose event data class derives from CommandEventArgs), any event defined on a server control can be bubbled.
- A control can participate in event bubbling through two methods that it inherits from the base class System.Web.UI.Control. These methods are OnBubbleEvent and RaiseBubbleEvent.
|