Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Método Control.OnBubbleEvent (Object, EventArgs)

 

Determina se o evento do controle de servidor é passado um nível acima da hierarquia de controle de servidor da interface do usuário da página.

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

protected virtual bool OnBubbleEvent(
	object source,
	EventArgs args
)

Parâmetros

source
Type: System.Object

A fonte do evento.

args
Type: System.EventArgs

Um objeto EventArgs que contém os dados do evento.

Valor Retornado

Type: System.Boolean

true se o evento tiver sido cancelado; caso contrário, false. O padrão é false.

ASP.NET server controls such as the T:System.Web.UI.WebControls.Repeater, T:System.Web.UI.WebControls.DataList and T:System.Web.UI.WebControls.GridView Web controls can contain child controls that raise events. For example, each row in a T:System.Web.UI.WebControls.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 E:System.Web.UI.WebControls.GridView.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 M:System.Web.UI.Control.OnBubbleEvent(System.Object,System.EventArgs) method in a custom ASP.NET server control, ParentControl. This method is invoked when a child control of ParentControl calls the M:System.Web.UI.Control.RaiseBubbleEvent(System.Object,System.EventArgs) method. When this happens, the ParentControl class writes two strings to the containing ASP.NET page, the first stating that its M:System.Web.UI.Control.OnBubbleEvent(System.Object,System.EventArgs) method has been called, the second identifying the source control of the M:System.Web.UI.Control.RaiseBubbleEvent(System.Object,System.EventArgs) 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);
   }
}

.NET Framework
Disponível desde 1.1
Retornar ao início
Mostrar: