.Net 2.0 has a PreInit event where the theme and master page can be set. When you are rolling your own theme or master page in v1.1, you need a time for the end page to set or override the them and master page. Here is how I created a PreInit event that fires before I wire up the theme and master page:
protected virtual event EventHandler PreInit;
protected new virtual event EventHandler Init;
protected new virtual event EventHandler Load;
protected new virtual event EventHandler PreRender;
protected new virtual event EventHandler Unload;
protected virtual void OnPreInit(EventArgs e) {
if(PreInit != null)
PreInit(this, e);
}
protected new virtual void OnInit(EventArgs e) {
if(Init != null)
Init(this, e);
}
protected new virtual void OnLoad(EventArgs e) {
if(Load != null)
Load(this, e);
}
protected new virtual void OnPreRender(EventArgs e) {
if(PreRender != null)
PreRender(this, e);
}
protected new virtual void OnUnload(EventArgs e) {
if(Unload != null)
Unload(this, e);
}
#endregion
#region Event Handlers
private void Page_Init(object sender, EventArgs e) {
Trace.Write(“EZWeb.Page”, “Begin PreInitialization”);
this.PreInitializePage();
Trace.Write(“EZWeb.Page”, “End PreInitialization”);
Trace.Write(“EZWeb.Page”, “Begin PreInit”);
OnPreInit(e);
Trace.Write(“EZWeb.Page”, “End PreInit”);
this.InitializePage();
Trace.Write(“EZWeb.Page”, “Begin Init”);
OnInit(e);
Trace.Write(“EZWeb.Page”, “End Init”);
}
I shadow the existing events in my base page and then control the raising of those events. In that way, I can do some work, raise PreInit, do some work, and raise Init. I chose this method particularly for the ease of migration to v2.0 next year.