Control.OnBubbleEvent(Object, EventArgs) Control.OnBubbleEvent(Object, EventArgs) Control.OnBubbleEvent(Object, EventArgs) Control.OnBubbleEvent(Object, EventArgs) Method

Definición

Determina si el evento del control de servidor se pasa a la jerarquía de control de servidor de la interfaz de usuario (UI) de la página.Determines whether the event for the server control is passed up the page's UI server control hierarchy.

protected:
 virtual bool OnBubbleEvent(System::Object ^ source, EventArgs ^ args);
protected virtual bool OnBubbleEvent (object source, EventArgs args);
abstract member OnBubbleEvent : obj * EventArgs -> bool
override this.OnBubbleEvent : obj * EventArgs -> bool
Protected Overridable Function OnBubbleEvent (source As Object, args As EventArgs) As Boolean

Parámetros

source
Object Object Object Object

Origen del evento.The source of the event.

args
EventArgs EventArgs EventArgs EventArgs

Objeto EventArgs que contiene los datos del evento.An EventArgs object that contains the event data.

Devoluciones

Es true si se ha cancelado el evento; en caso contrario, es false.true if the event has been canceled; otherwise, false. De manera predeterminada, es false.The default is false.

Ejemplos

En el ejemplo siguiente se invalida el OnBubbleEvent método en un control de servidor ASP.NET personalizado, ParentControl.The following example overrides the OnBubbleEvent method in a custom ASP.NET server control, ParentControl. Este método se invoca cuando un control secundario de ParentControl llamadas la RaiseBubbleEvent método.This method is invoked when a child control of ParentControl calls the RaiseBubbleEvent method. Cuando esto sucede, el ParentControl clase escribe dos cadenas en la página ASP.NET que lo contiene, el primer sistema que indique que su OnBubbleEvent se ha llamado al método, la segunda que identifica el control de código fuente de la RaiseBubbleEvent método.When this happens, the ParentControl class writes two strings to the containing ASP.NET page, the first stating that its OnBubbleEvent method has been called, the second identifying the source control of the RaiseBubbleEvent method.

public class ParentControl : Control 
{
   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
   protected override bool OnBubbleEvent(object sender, EventArgs e)
   {
      Context.Response.Write("<br><br>ParentControl's OnBubbleEvent called.");
      Context.Response.Write("<br>Source of event is: " + sender.ToString());
      return true;
   }
   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
   protected override void Render( HtmlTextWriter myWriter)
   {
      myWriter.Write("ParentControl");
      RenderChildren(myWriter);
   }
}
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
 _

Comentarios

Controles de servidor ASP.NET como el Repeater, DataList y GridView controles Web pueden contener los controles secundarios que provocan eventos.ASP.NET server controls such as the Repeater, DataList and GridView Web controls can contain child controls that raise events. Por ejemplo, cada fila de un GridView control puede contener uno o varios botones creados dinámicamente mediante plantillas.For example, each row in a GridView control can contain one or more buttons created dynamically by templates. En lugar de cada botón provoque un evento individualmente, los eventos de los controles anidados hacen una "burbuja", es decir, se envían al contenedor de nomenclatura.Rather than each button raising an event individually, events from the nested controls are "bubbled" - that is, they are sent to the naming container. El contenedor de nomenclatura a su vez provoca un evento genérico denominado RowCommand con valores de parámetro.The naming container in turn raises a generic event called RowCommand with parameter values. Estos valores permiten determinar qué control individual que provocó el evento original.These values allow you to determine which individual control that raised the original event. Al responder a un único evento, puede evitar tener que escribir métodos de control de eventos individuales para los controles secundarios.By responding to this single event, you can avoid having to write individual event-handling methods for child controls.

Se aplica a

Consulte también: