Jeff and .NET

The .NET musings of Jeff Putz

Sponsors

News

My Sites

Archives

Set a theme from a MasterPage?

Am I missing something ridiculously obvious? MasterPage has no Theme property, but it would certainly make sense to me to be able to set a theme at the MasterPage level. Searching the asp.net forums, it appears it can't be done.

Please tell me this will be changed for beta 2. I just can't imagine having this great feature and not being able to do it at the higher level.
Posted: Apr 12 2005, 10:16 PM by Jeff | with 9 comment(s)
Filed under:

Comments

Fredrik Normén said:

You can't set a theme in Beta 2 either on a Master Page.
# April 13, 2005 4:59 AM

Hannes Preishuber said:

you can set the theme in web.config
or per code
# April 13, 2005 7:57 AM

Jeff said:

I'm aware of that... but it's not what I want.

It sure seems like an obvious problem. I can't believe they didn't change it.
# April 13, 2005 8:32 AM

Lee said:

Nice, Brock.. Thanks for the blog Jeff.

# November 14, 2006 11:49 AM

Paul Anthony said:

It does seem a bit short sighted not to include this property - and still nothing in 3.5

# September 18, 2008 6:08 AM

Damian said:

Please, my english is not good, but...one question

Set the "Theme" property in the web.config file, dinamically...impossible? I 'm trying develop a dynamic CMS application using templates and I'need change the web site styles dinamically in run time.

Thanks!

Damián

# April 8, 2010 1:42 AM

Damián said:

In my last post I'forget comment: Right now, I'm set the theme page property in the OnPreInit override method.

But, on this way is neccesary repeat the same code in all the web site pages, for this reason I'm search other more efficient alternative.

Thanks!!!

# April 8, 2010 2:23 AM

SENTHIL said:

You can create a new class called "BasePage" or "BaseClass" that inherits from System.Web.UI.Page, then you can override the preinit method where you can set the theme, once done all the page you will add or exist should inherit from the "BasePage" or "BaseClass" - code is shown below.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

namespace yournamespace

{

   public class BasePage : Page

   {

       public BasePage()

       {

       }

       protected override void OnPreInit(EventArgs e)

       {

           base.OnPreInit(e);

           var themeName = "SiteTheme"; // Default theme

           if (Session["org"] != null)

           {

               switch (Session["org"].ToString()) //Change theme based on organization

               {

                   case "A": themeName = "A"; break;

                   case "B": themeName = "A"; break;

                   case "C": themeName = "A"; break;                  

               }

               this.Page.Theme = themeName; //Name of the theme folder found under "App_Themes"

           }

       }

   }

}

# March 21, 2011 11:05 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)