DataPager.OnInit(EventArgs) DataPager.OnInit(EventArgs) DataPager.OnInit(EventArgs) DataPager.OnInit(EventArgs) Method


引發 Init 事件。Raises the Init event.

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


EventArgs EventArgs EventArgs EventArgs

事件資料。The event data.


當此方法收到通知時, Web 服務器控制項必須執行所需的任何初始化步驟, 才能建立和設定實例。When notified by this method, Web server controls must perform any initialization steps that are required in order to create and set up an instance. 在伺服器控制項生命週期的這個階段中, 尚未填入控制項的檢視狀態。In this stage of the server control's life cycle, the control's view state has not yet been 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 guaranteed to be created and ready for access.

引發事件會透過委派叫用此事件處理常式。Raising an event invokes the event handler through a delegate. 如需詳細資訊, 請參閱處理和引發事件For more information, see Handling and Raising Events.

OnInit方法也可讓衍生類別處理事件, 而不需要附加委派。The OnInit method also enables derived classes to handle the event without attaching a delegate. 這是在衍生類別中處理事件的慣用技巧。This is the preferred technique for handling the event in a derived class.


當您在OnInit(EventArgs)衍生類別中覆寫時, 請務必呼叫基類OnInit(EventArgs)的方法, 讓已註冊的委派能接收事件。When you override OnInit(EventArgs) in a derived class, make sure that you call the base class' OnInit(EventArgs) method so that registered delegates receive the event.