Page.OnPreInit(EventArgs) 方法

定义

在页初始化开始时引发 PreInit 事件。Raises the PreInit event at the beginning of page initialization.

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

参数

e
EventArgs

包含事件数据的 EventArgsAn EventArgs that contains the event data.

注解

OnPreInit方法在页初始化阶段开始时调用。The OnPreInit method is called at the beginning of the page initialization stage.

OnPreInit调用方法后,将加载个性化设置信息并初始化页面主题(如果有)。After the OnPreInit method is called, personalization information is loaded and the page theme, if any, is initialized. 这也是动态定义 PageTheme 页面或的首选阶段 MasterPageThis is also the preferred stage to dynamically define a PageTheme or MasterPage for the Page.

引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息,请参阅 处理和引发事件For more information, see Handling and Raising Events.

OnPreInit 方法还允许派生类对事件进行处理而不必附加委托。The OnPreInit 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.

继承者说明

在派生类中重写 OnPreInit(EventArgs) 时,一定要调用基类的 OnPreInit(EventArgs) 方法,以便已注册的委托对事件进行接收。When overriding OnPreInit(EventArgs) in a derived class, be sure to call the base class's OnPreInit(EventArgs) method so that registered delegates receive the event.

适用于