change masterpage based on the folder
I guess I'm wide awake. While looking for something else, I came across this, I'm sure someone could use it.
Add this code to the OnPreInit() of the basepage. In this example, the masterpage changes to a 2 column layout from a 3 column layout if the page is in the '/forum' or '/classifieds' folder.
public class BasePage : System.Web.UI.Page
{
protected override void OnPreInit(EventArgs e)
{
string inf = System.IO.Path.GetDirectoryName(Request.Path);
string homesection = inf.Substring(inf.LastIndexOf("\\") + 1).ToLower();
if (homesection == "forum" || homesection == "classifieds")
{
Page.MasterPageFile = "~/_components/masterpages/2ColFaux.master";
}
else
{
Page.MasterPageFile = "~/_components/masterpages/3ColFaux.master";
}
base.OnPreInit(e);
}
}
Crab
|