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