Control.OnInit(EventArgs) Control.OnInit(EventArgs) Control.OnInit(EventArgs) Control.OnInit(EventArgs) Method

定義

引發 Init 事件。Raises the Init event.

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 EventArgs EventArgs

包含事件資料的 EventArgs 物件。An EventArgs object that contains the event data.

範例

// Override the OnInit method to set _text to
// a default value if it is null.
[System.Security.Permissions.PermissionSet
    (System.Security.Permissions.SecurityAction.Demand, 
     Name="FullTrust")] 
protected override void OnInit(EventArgs e)
{
   base.OnInit(e);
   if ( _text == null)
        _text = "Here is some default text.";
}
' Override the OnInit method to set _text to 
' a default value if it is null.
<System.Security.Permissions.PermissionSetAttribute( _
  System.Security.Permissions.SecurityAction.Demand, _
    Name:="FullTrust")> _
Protected Overrides Sub OnInit(ByVal e As EventArgs)
    MyBase.OnInit(e)
    If _text Is Nothing Then
        _text = "Here is some default text."
    End If
End Sub 'OnInit

備註

ASP.NET 會呼叫此方法以引發Init事件。ASP.NET calls this method to raise the Init event. 如果您正在開發的自訂控制項,您可以覆寫這個方法以提供額外的處理。If you are developing a custom control, you can override this method in order to provide additional processing. 如果您覆寫這個方法,呼叫基底控制項的OnInit方法來通知事件的訂閱者。If you override this method, call the base control's OnInit method to notify subscribers to the event.

適用於

另請參閱