UserControl.OnInit(EventArgs) 方法


引發 Init 事件。Raises the Init event.

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



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


當此方法收到通知時, UserControl 必須執行建立和設定實例所需的任何初始化步驟。When notified by this method, the UserControl must perform any initialization steps that are required to create and set up an instance. 這個方法會確認與實例相關聯的網站資訊 UserControl ,並確保類別已正確初始化為 UserControl 物件。This method confirms site information associated with the UserControl instance and ensures that the class is initialized correctly as a UserControl object.

在使用者控制項生命週期的這個階段中,控制項的檢視狀態尚未填入。In this stage of the user control's lifecycle, the control's view state has yet to be populated. 此外,當呼叫這個方法時,您無法存取其他伺服器控制項,不論它是此控制項的子系或父系。Additionally, you cannot access other server controls when this method is called, regardless of whether it is a child or parent to this control. 其他伺服器控制項則不一定要建立並準備好進行存取。Other server controls are not certain to be created and ready for access.