Control.OnInit(EventArgs) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
引發 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)
參數
範例
// 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
備註
ASP.NET 呼叫此方法來提升 Init 事件。 如果你正在開發自訂控制,可以覆寫此方法以提供額外的處理。 如果你覆寫了這個方法,請呼叫基地控制 OnInit 的方法來通知訂閱者事件。