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.

适用于

另请参阅