ControlAdapter.OnInit(EventArgs) 메서드

정의

연결된 컨트롤의 OnInit(EventArgs) 메서드를 재정의합니다.

protected public:
 virtual void OnInit(EventArgs ^ e);
protected internal virtual void OnInit (EventArgs e);
abstract member OnInit : EventArgs -> unit
override this.OnInit : EventArgs -> unit
Protected Friend Overridable Sub OnInit (e As EventArgs)

매개 변수

e
EventArgs

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

예제

다음 코드 샘플은 클래스에서 사용자 지정 컨트롤 어댑터를 파생합니다 ControlAdapter . 그런 다음 메서드를 재정의 OnInit 하여 연결된 컨트롤에서 속성을 설정하고 기본 메서드를 호출하여 컨트롤 초기화를 완료합니다.

#using <System.Web.dll>
#using <System.dll>

using namespace System;
using namespace System::Web::UI;
using namespace System::Web::UI::Adapters;

public ref class CustomControlAdapter: public ControlAdapter
{
   // Override the ControlAdapter default OnInit implementation.
protected:
   virtual void OnInit( EventArgs^ e ) override
   {
      // Make the control invisible.
      Control->Visible = false;
      
      // Call the base method, which calls OnInit of the control,
      // which raises the control Init event.
      ControlAdapter::OnInit( e );
   }
};
using System;
using System.Web.UI;
using System.Web.UI.Adapters;

public class CustomControlAdapter : ControlAdapter
{
    // Override the ControlAdapter default OnInit implementation.
    protected override void OnInit (EventArgs e)
    {
        // Make the control invisible.
        Control.Visible = false;

        // Call the base method, which calls OnInit of the control,
        // which raises the control Init event.
        base.OnInit(e);
    }
}
Imports System.Web.UI
Imports System.Web.UI.Adapters

Public Class CustomControlAdapter
    Inherits ControlAdapter

    ' Override the ControlAdapter default OnInit implementation.
    Protected Overrides Sub OnInit(ByVal e As EventArgs)

        ' Make the control invisible.
        Control.Visible = False

        ' Call the base method, which calls OnInit of the control, 
        ' which raises the control Init event.
        MyBase.OnInit(e)

    End Sub
End Class

설명

개체에 Control 연결된 어댑터가 있고 메서드가 OnInit 재정의된 경우 재정의 Control.OnInit 메서드가 메서드 대신 호출됩니다.

OnInit 재정의하여 제어 수명 주기 단계에서 대상별 처리를 Initialize 수행합니다. 일반적으로 이러한 함수는 컨트롤을 만들 때 수행됩니다.

상속자 참고

클래스에서 ControlAdapter 상속하고 어댑터가 메서드를 재정 OnInit(EventArgs) 의하는 경우 어댑터는 해당 기본 클래스 메서드를 호출해야 하며, 이 메서드는 메서드를 OnInit(EventArgs) 호출합니다. 메서드가 OnInit(EventArgs) 호출 Init 되지 않으면 이벤트가 발생하지 않습니다.

적용 대상

추가 정보