Tuesday, October 23, 2007

Themes in .net

Here's the situation, I'm trying to use one theme for the entire site. I also want individuals to allow themselves to change the theme of their areas.

Here's what I found:
  • http://msdn2.microsoft.com/en-us/library/950xf363.aspx
  • Had to investigate the web.config. In doing so, found the pages property maintainScrollPositionOnPostBack. I thought this was great. So, I set it to true considering all of the forms we have
  • Set pages property smartNavigation="true" to see how it worked.
  • Had issues because I couldn't understand how the theme and the master page interacted. I ended up reading this article...http://msdn2.microsoft.com/en-us/library/wtxbf3hh(VS.80).aspx After reading it, I found out that master pages inherit the theme from their calling pages. Here's an excerpt:
  • Master Pages and Themes
    You cannot directly apply an ASP.NET theme to a master page. If you add a theme attribute to the @ Master directive, the page will raise an error when it runs.
    However, themes are applied to master pages under these circumstances:
    If a theme is defined in the content page. Master pages are resolved in the context of content pages, so the content page's theme is applied to the master page as well.
    If the site as a whole is configured to use a theme by including a theme definition in the
    pages Element (ASP.NET Settings Schema) element.
  • Also learned that you can set the master page based on the page level, folder level (interesting for admin backends), and the application level (web.config)
  • It did appear that when I added a new stylesheet to the app_themes directory, it took a minute to load. Essentially, at one point, i thought i had to update the .master file to see the difference. Although, i think that was just timing.
  • Cool thing. If I add a stylesheet to the app_themes folder theme, it is automatically added as a property for this theme. So, i don't have to reference it in my file.

No comments: