Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

Control.RaiseBubbleEvent Method

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

[Visual Basic]
Protected Sub RaiseBubbleEvent( _
   ByVal source As Object, _
   ByVal args As EventArgs _
)
[C#]
protected void RaiseBubbleEvent(
 object source,
 EventArgs args
);
[C++]
protected: void RaiseBubbleEvent(
 Object* source,
 EventArgs* args
);
[JScript]
protected function RaiseBubbleEvent(
   source : Object,
 args : EventArgs
);

Parameters

source
The source of the event.
args
An EventArgs object that contains the event data.

Remarks

ASP.NET server controls such as the Repeater, DataList and DataGrid Web controls can contain child controls that raise events. For example, each row in a DataGrid 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 ItemCommand 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. For more information, see Bubbling an Event.

Example

[Visual Basic, C#, C++] The following example is a custom class, ChildControl, that overrides 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.

[Visual Basic] 
Public Class ChildControl
   Inherits Button
   
   <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
   Protected Overrides Sub OnClick(e As EventArgs)
      MyBase.OnClick(e)
      Context.Response.Write("<br><br>ChildControl's OnClick called.")
      ' Bubble this event to parent.
      RaiseBubbleEvent(Me, e)
   End Sub 'OnClick
End Class 'ChildControl 

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

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Web.UI Namespace | OnBubbleEvent | Bubbling an Event

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.