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.

9 Comments

  • You can't set a theme in Beta 2 either on a Master Page.

  • you can set the theme in web.config

    or per code

  • 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.

  • I posted about this:



    http://staff.develop.com/ballen/blog/PermaLink.aspx?guid=09befce7-f48e-4555-891c-13818fd75a56

  • Nice, Brock.. Thanks for the blog Jeff.

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

  • 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

  • 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!!!

  • 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"
    }
    }
    }
    }

Comments have been disabled for this content.