Control.OnBubbleEvent(Object, EventArgs) 메서드

정의

서버 컨트롤의 이벤트가 페이지의 UI 서버 컨트롤 계층 구조에 전달되었는지 여부를 확인합니다.

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

매개 변수

source
Object

이벤트 소스입니다.

args
EventArgs

이벤트 데이터가 포함된 EventArgs 개체입니다.

반환

이벤트가 취소되었으면 true를 반환하고, 그렇지 않으면 false를 반환합니다. 기본값은 false입니다.

예제

다음 예제에서는 사용자 지정 ASP.NET 서버 컨트롤에서 메서드를 재정 OnBubbleEvent 의합니다 ParentControl. 이 메서드는 의 ParentControl 자식 컨트롤이 메서드를 호출할 때 호출됩니다 RaiseBubbleEvent . 이 경우 클래스는 ParentControl 포함하는 ASP.NET 페이지에 두 개의 문자열을 씁니다. 첫 번째는 메서드 OnBubbleEvent 가 호출되었음을 나타내는 것이며, 두 번째 문자열은 메서드의 RaiseBubbleEvent 소스 제어를 식별합니다.

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
End Class
 _

설명

와 같은 RepeaterDataList ASP.NET 서버 컨트롤 및 GridView 웹 컨트롤에는 이벤트를 발생시키는 자식 컨트롤이 포함될 수 있습니다. 예를 들어 컨트롤의 GridView 각 행에는 템플릿으로 동적으로 만든 하나 이상의 단추가 포함될 수 있습니다. 이벤트를 개별적으로 발생시키는 각 단추 대신 중첩된 컨트롤의 이벤트는 "버블링"됩니다. 즉, 명명 컨테이너로 전송됩니다. 명명 컨테이너는 매개 변수 값을 사용하여 라는 RowCommand 제네릭 이벤트를 발생합니다. 이러한 값을 사용하면 원래 이벤트를 발생시킨 개별 컨트롤을 확인할 수 있습니다. 이 단일 이벤트에 응답하면 자식 컨트롤에 대한 개별 이벤트 처리 메서드를 작성할 필요가 없습니다.

적용 대상

추가 정보