Page.PreInit Page.PreInit Page.PreInit Page.PreInit Event


在页初始化之前发生。Occurs before page initialization.

 event EventHandler ^ PreInit;
public event EventHandler PreInit;
member this.PreInit : EventHandler 
Public Custom Event PreInit As EventHandler 


此事件使你可以检查页面请求的条件, 例如是否加载页面以响应回发。This event enables you to check conditions of the page request, such as whether the page is being loaded in response to a postback. 还可以检查配置文件属性的值。You can also check the values of profile properties.

使用事件可以设置稍后在页面生命周期中使用的值。The event enables you to set values that are used later in the page life cycle. 您可以为请求的页面动态设置母版页或主题, 并创建动态控件。You can dynamically set a master page or a theme for the requested page, and create dynamic controls.

有关PreInit事件如何适应 ASP.NET 生命周期的详细信息, 请参阅ASP.NET 页面生命周期概述For more information about how the PreInit event fits into the ASP.NET life cycle, see ASP.NET Page Life Cycle Overview.