Share via


Control.OnInit(EventArgs) Metode

Definisi

Memunculkan kejadian Init.

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

Parameter

e
EventArgs

Objek EventArgs yang berisi data peristiwa.

Contoh

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

Keterangan

ASP.NET memanggil metode ini untuk meningkatkan Init peristiwa. Jika Anda mengembangkan kontrol kustom, Anda dapat mengambil alih metode ini untuk menyediakan pemrosesan tambahan. Jika Anda mengambil alih metode ini, panggil metode kontrol OnInit dasar untuk memberi tahu pelanggan peristiwa.

Berlaku untuk

Lihat juga