Control.RaiseBubbleEvent(Object, EventArgs) 메서드

정의

이벤트 소스와 해당 정보를 컨트롤의 부모 컨트롤에 할당합니다.

protected:
 void RaiseBubbleEvent(System::Object ^ source, EventArgs ^ args);
protected void RaiseBubbleEvent (object source, EventArgs args);
member this.RaiseBubbleEvent : obj * EventArgs -> unit
Protected Sub RaiseBubbleEvent (source As Object, args As EventArgs)

매개 변수

source
Object

이벤트 소스입니다.

args
EventArgs

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

예제

다음 코드 예제에서는 사용자 지정 클래스를 만드는 방법을 보여 줍니다., ChildControl를 재정의 Button.OnClickRaiseBubbleEvent 하는 메서드를 호출 하는 메서드를 부모 ASP.NET 서버 컨트롤에 이벤트를 보냅니 Button.Click 다. 사용자가 의 instance 포함된 ASP.NET 페이지에서 단추를 클릭하면 의 ChildControlinstance ChildControl 포함된 부모 컨트롤에서 메서드를 발생 OnBubbleEvent 시키고 "ChildControl 클래스 OnClick 메서드가 호출됩니다." 문자열을 페이지에 씁니다.

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);
   }
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
End Class

설명

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

이 메서드를 재정의할 수는 없지만 작성자 컨트롤은 메서드를 재정 OnBubbleEvent 의하여 버블링된 이벤트를 처리하거나 발생할 수 있습니다.

적용 대상

추가 정보