Control.OnBubbleEvent Method (Object, EventArgs)
Determines whether the event for the server control is passed up the page's UI server control hierarchy.
Assembly: System.Web (in System.Web.dll)
Protected Overridable Function OnBubbleEvent ( source As Object, args As EventArgs ) As Boolean
The source of the event.
Return ValueType: System.Boolean
true if the event has been canceled; otherwise, false. The default is false.
ASP.NET server controls such as the Repeater, DataList and GridView Web controls can contain child controls that raise events. For example, each row in a GridView control can contain one or more buttons created dynamically by templates. Rather than each button raising an event individually, events from the nested controls are "bubbled"—that is, they are sent to the naming container. The naming container in turn raises a generic event called RowCommand with parameter values. These values allow you to determine which individual control that raised the original event. By responding to this single event, you can avoid having to write individual event-handling methods for child controls.
The following example overrides the ParentControl. This method is invoked when a child control of ParentControl calls the RaiseBubbleEvent method. When this happens, the ParentControl class writes two strings to the containing ASP.NET page, the first stating that its method has been called, the second identifying the source control of the RaiseBubbleEvent method.method in a custom ASP.NET server control,
Public Class ParentControl Inherits Control <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Function OnBubbleEvent(sender As Object, e As EventArgs) As Boolean Context.Response.Write("<br><br>ParentControl's OnBubbleEvent called.") Context.Response.Write(("<br>Source of event is: " + sender.ToString())) Return True End Function 'OnBubbleEvent <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Sub Render(myWriter As HtmlTextWriter) myWriter.Write("ParentControl") RenderChildren(myWriter) End Sub 'Render End Class 'ParentControl _
Available since 1.1