My Development Notes

By Haemoglobin
3/10/2010 (revision 1)

Master Pages

  • A master page (.master) defines a set of ContentPlaceHolder controls
  • Content pages define a Content control for each ContentPlaceHolder control defined in the master page it is linked to (MasterPageFile="~/MySite.Master" in the page declarative).
  • Use

    <%@ MasterType VirtualPath="~/MySite.Master" > 
    

    To access public properties defined in that class like:

    Master.UserId
    

  • A master page can also define a MasterPageFile (as the parent) and implement some Content controls, and defining more ContentPlaceHolder controls within them for child controls.
  • The master page can be set dynamically in code by setting the MasterPageFile property.

    Session["masterpage"] = "AnotherMaster.master"; 
    Response.Redirect(Request.Url.ToString()); 
    
    //Then in PreInit
    MasterPageFile = (string) Session["masterpage"]; 
    
    

  • Themes

    • Each theme has it's own folder in the App_Themes folder. Folder contains a .skin file, .css and images/resources.
    • Skin file looks like:
      <asp:Button runat="server" BackColor="Red"/>
      
      <asp:Image runat="server" SkinId="CompanyLogo" ImageUrl="~/App_Themes/Fabrikam/fabrikam.jpg/>
      
    • If SkinId not applied, applies to all controls of that type. Otherwise applied to controls that have a matching SkinId. property.
    • The css file is automatically linked into the header of the masterpage.
    • Order of precedence for applying themes (higher numbers override lower numbers):
      1. Theme attribute in Page directive.
      2. <pages Theme="themeName"> in the web.config file
      3. Local control attributes
      4. StyleSheetTheme in the page directive.
      5. <pages StyleSheetTheme="themeName"> in the web.config file.
    • Can be set dynamically in PreInit using Page.Theme = "ThemeName" or Page.StyleSheetTheme = "ThemeName";

Comments

Powered by BlogEngine.NET 1.6.1.0 | Design by styleshout | Enhanced by GravityCube.net | 1.4.5 Changes by zembian.com | Adapted by HamishGraham.NET
(c) 2010 Hamish Graham. Banner Image (c) Chris Gin