Page.OnPreLoad(EventArgs) Page.OnPreLoad(EventArgs) Page.OnPreLoad(EventArgs) Page.OnPreLoad(EventArgs) Method


在回傳資料載入頁面伺服器控制項之後,但在 PreLoad 事件之前,引發 OnLoad(EventArgs) 事件。Raises the PreLoad event after postback data is loaded into the page server controls but before the OnLoad(EventArgs) event.

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


EventArgs EventArgs EventArgs EventArgs

包含事件資料的 EventArgsAn EventArgs that contains the event data.


OnPreLoad方法呼叫傳回的使用者畢竟回傳資料載入。The OnPreLoad method is called after all postback data returned from the user is loaded. 在這個階段中網頁的生命週期中,檢視狀態資訊回傳資料宣告和控制項和控制項的初始化階段期間建立,都會載入網頁的控制項。At this stage in the page's life cycle, view-state information and postback data for declared controls and controls created during the initialization stage are loaded into the page's controls.

在中建立的控制項OnPreLoad方法也會載入檢視狀態和回傳資料。Controls created in the OnPreLoad method will also be loaded with view-state and postback data.

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

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


當在衍生類別中覆寫 OnPreLoad(EventArgs) 時,請確定呼叫基底類別的 OnPreLoad(EventArgs) 方法,使已註冊的委派能接收到事件。When overriding OnPreLoad(EventArgs) in a derived class, be sure to call the base class's OnPreLoad(EventArgs) method so that registered delegates receive the event.