in

ASP.NET Weblogs

[karsten samaschke]

ASP.NET daily. Or weekly.

Master-Page-Limitation in ASP.NET 2.0

The concept of Masterpages introduced in ASP.NET “Whidbey” is really fascinating. But it seems to have one major limitation, which appears to make it quite unusable in bigger Web-Applications: There seems to be no functionality, which allows a developer to programmatically change the used Master-Page at runtime.

If you think so, you should read this article: http://msdn.microsoft.com/msdnmag/issues/04/06/ASPNET20MasterPages/default.aspx

After reading this, you'll be able to change the MasterPage at runtime using the new PreInit-Event:

protected override void OnPreInit(EventArgs e)
{
  this.MasterPageFile = "OtherTemplate.master";
  base.OnPreInit(e);
}

Protected Overrides Sub OnPreInit(ByVal e As EventArgs)
   Me.MasterPageFile = "OtherTemplate.master"
   MyBase.OnPreInit(e)
End Sub

And after all, the concepts of MasterPages should work. :-)

Thanks to Scott Galloway (http://www.mostlylucid.co.uk) for his hint on this topic.

Published Jun 15 2004, 09:09 PM by xxxkarsan3020
Filed under: ,

Comments

 

Fredrik Normén NSQUARED2 said:

I will also add a comment that you could also change the Theme (skin) for a page and that must also be done in the OnPreInit event of the page.
June 15, 2004 5:14 PM
 

TrackBack said:

June 28, 2004 1:39 PM
 

Ephedrine phpbb forum. said:

Ephedrine faq ephedrine fatloss. Ephedrine. Ephedrine products. Ephedrine in salt licks and chicken feed. Ephedrine weight loss products.

July 30, 2008 3:08 AM

Leave a Comment

(required)  
(optional)
(required)  
Add