RaiseBubbleEvent Method

Control.RaiseBubbleEvent Method (Object, EventArgs)


Assigns any sources of the event and its information to the control's parent.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

protected void RaiseBubbleEvent(
	object source,
	EventArgs args


Type: System.Object

The source of the event.

Type: System.EventArgs

An EventArgs object that contains the event data.

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 control's parent. The parent 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.

While you cannot override this method, controls you author can handle or raise bubbled events by overriding the OnBubbleEvent method.

The following code example demonstrate how to create a custom class, ChildControl, overriding the Button.OnClick method to call the RaiseBubbleEvent method that sends the Button.Click event to its parent ASP.NET server control. When the user clicks a button in an ASP.NET page that includes an instance of ChildControl, it raises the OnBubbleEvent method on the parent control that contains the instance of ChildControl and writes the string "The ChildControl class OnClick method is called" to the page.

public class ChildControl : Button
   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
   protected override void OnClick(EventArgs e) 
      Context.Response.Write("<br><br>ChildControl's OnClick called.");
      // Bubble this event to parent.
      RaiseBubbleEvent(this, e);

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft