Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2008, 09:21 AM
Registered User
 
Join Date: Feb 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to crab
Default 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
 
Old April 14th, 2008, 03:10 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Neato :) One thing I'd recommend you to do, though, is move the list of "special" folders to the web.config. That way, if you end up tweaking more, you can load it from a single place, rather than hard-coding it.

Cheers,

Peter

http://entropia-online.blogspot.com/
 
Old April 14th, 2008, 09:32 AM
Registered User
 
Join Date: Feb 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to crab
Default

Mais oui, Peter.

Crab






Similar Threads
Thread Thread Starter Forum Replies Last Post
MasterPage in different folder / level bananas ASP.NET 2.0 Basics 0 January 3rd, 2007 12:37 PM
Change value based on other value 2BOrNot2B XSLT 3 December 21st, 2006 08:19 PM
Change folder DACLs rmortega77 C# 0 August 3rd, 2006 10:42 AM
Change SecurityDescriptor of Folder from Client jmtoet Pro VB 6 0 June 12th, 2005 12:04 PM
Change Default Existing Project Folder ritag Beginning VB 6 2 February 9th, 2004 05:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.