CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 9/7/2007 8:53:21 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 11 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
dgoyette
Asp.Net User
Customizing Master Pages (Best Approaches)9/7/2007 8:53:21 PM

0/0

This question is somewhat vague, and I imagine there's no single "best" answer. But I welcome the experiences of others, and how they've approached similar issues.

The basic idea is, I like the idea of using Master Pages for my website, for things like the main logo and navigation. But with all but the simplest navigation, there will be individual customization on any given page. As a terribly simple example of what I mean, go to http://www.cnn.com. Navigate their various "tabs" along the top (Home, World, U.S., Politics, etc). When you click the tab, it brings you to that page, but the menu is altered slightly such that the current tab is highlighted. I'm not interested in the specific implementation of their website, it's just the concept I'm referring to.

So, the real question being put forth in this post is, what's the best way to approach the idea of Master Page content that has individual customization on a given page? From my limited investigation, I've got the following ideas. I don't know if one is better than the rest, or if there's a whole different method that's much better, but here they are:

1) Nested Master Pages

Let's say my website has a navigation menu with "Home", "Contact", "Pictures" and "Misc" as menu links. When you're on one of these pages, that menu option should be highlighted.  And for each of these topics, I want a different image displayed towards the top of the page. So, that's pretty simple. The approach here would be to create a Master Page that contains ContentPlaceholders for the areas that might change. So, in the Master Page, there would be a full layout, with several ContentPlaceholders, with default contents for each of the menu buttons, as well as the image area. In general, just using this Master Page would produce a good looking page, with no customization. But now I make another Master Page that uses the first Master Page, and I override the contents of the ContentPlaceholders. So, on the "Home" Master Page, I'd override the contents of "ContentPlaceHolder_Home", for example, with a button that uses a different CSS class, so that the menu button will be highlighted.

That's just a simple idea. The bad thing about it is that VS 2005 doesn't offer Design mode when using Nested Master Pages. I've seen the hack to get around it, and wondered if it was the best way to go, or if that was sloppy.

 

2) Accessing Master Page data in the Content page

In this case, I'd have a Control in the Master Page, which handles all the settings for the menu and the page image. The Content page would use the Master page, and would programatically, on Page_Load, modify certain values. This idea seems simple enough, but it feels a little sloppy, since every page using the Master Page would need the extra code to handling custom preferences.

 

3) Accessing Content Page data in the Master Page

This is kind of the reverse of the 2nd example. In this case, I'd create a custom control, which is used in the Content page. It might be something like this:

 
<MyPrefix:MyControl ID="ctrl1" runat="server"
    highlight="Home"
    menuImage="banner_2.png"
/>

  

Then, the Master Page would check for a MyControl object when it's loaded, and override its contents if it finds one. This means that setting up a new page is fairly simple, registering and calling just a single control, which informs the Master Page on what to do. I'm leaning towards this one, just for the simplicity of it.

 

 

Anyway, those are my ideas. Is there a very different way of going about things in this manner? I'm interested in what others have done with this sort of thing.

 

-Dan 

jose_jimenez
Asp.Net User
Re: Customizing Master Pages (Best Approaches)9/7/2007 9:04:38 PM

0/0

Most of the navigation controls allow you to set the "selected" node.  Each selected item property can have a specific style set applied to it.  there is no need to set it at the content page level.  The code or control on the master page handles it.  the page load event of the master page can check which child page is loaded and do something to one of the controls on the master page.  The master page can have default content in a contentplace holder.   Individual pages can override the content in these contenet place holders.  Given this, why "customize" the way master pages work?  Try basing your menu on a web.sitemap using a sitemap datasource and you won't have to code anything, but will still get selected items.  Just style the selected item for color changes.

 

--JJ


Please mark as answered if I helped.
I don't answer personal emails unless I know you or of you. Feel free to post in the forum to get an answer from me.
Amanda Wang - M
Asp.Net User
Re: Customizing Master Pages (Best Approaches)9/11/2007 3:41:46 AM

0/0

Hi,

dgoyette:

2) Accessing Master Page data in the Content page

In this case, I'd have a Control in the Master Page, which handles all the settings for the menu and the page image. The Content page would use the Master page, and would programatically, on Page_Load, modify certain values. This idea seems simple enough, but it feels a little sloppy, since every page using the Master Page would need the extra code to handling custom preferences.

About the accessing the master page data in the content page, there are two menthod:

1. You can use the findcontrol method to get the master page's controls. there is a master property in the page object, it can implement to refer the master page.

2.You also can use the mastertype commond to access the master page's propertyhttp://msdn2.microsoft.com/en-us/library/ms228274.aspx  )

dgoyette:

3) Accessing Content Page data in the Master Page

This is kind of the reverse of the 2nd example. In this case, I'd create a custom control, which is used in the Content page. It might be something like this:

<MyPrefix:MyControl ID="ctrl1" runat="server"
    highlight="Home"
    menuImage="banner_2.png"
/>

Then, the Master Page would check for a MyControl object when it's loaded, and override its contents if it finds one. This means that setting up a new page is fairly simple, registering and calling just a single control, which informs the Master Page on what to do. I'm leaning towards this one, just for the simplicity of it.

About Accessing Content Page data in the Master Page, you also can try to refer a base class that inherit the System.Web.UI.page class without the aspx file.

You can make the content page inherit this base class and override the functions and the properties. and you need to set the functions and the properties are virtual, the content page can bind these functions and properties, so you can access the content page data in the master page.

Below is a sample:

1. Define a base class inherit from the system.web.ui.page without the aspx file, only is a cs file.

BasePage.cs?
public class BasePage :Page
{
    /// <summary>
    /// Output the welcome message of each content page, the content page need to inherit this function and override it, and this function can be called on the   master page.
    /// </summary>
    public virtual string SayHello()
    {
        return "This welcome message is return by the base page class!";
    }
}

2.The content page inherit the BasePage class, and override the functions.

Default.aspx.cs:
//Please notice, the page must  inherit the BasePage class

public partial class Template_Default : BasePage
//override the welcome function

    public override string SayHello()
    {
        return "This is the content page welcome message?";
    }

3. Access the content page data on the master page.

BasePage currentPage = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        currentPage = Page as BasePage;
    }

    protected void CallContentMethod_Click(object sender, EventArgs e)
    {
        if (currentPage != null)
        {
            welcomeMessage.Text = currentPage.SayHello();
        }
    }

Hope it helps.


 


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
SharePoint 2007 and Office Development Expert Solutions: Expert Solutions Authors: Randy Holloway, Andrej Kyselica, Steve Caravajal, Pages: 324, Published: 2007
Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter Kit: visual web developer 2005 express edition starter kit Authors: David Sussman, Alex Homer, Pages: 312, Published: 2005
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Professional ASP.NET 2.0 Databases Authors: Thiru Thangarathinam, Pages: 504, Published: 2007
Professional ASP.NET 2.0 XML Authors: Thiru Thangarathinam, Pages: 566, Published: 2005
Essential SharePoint 2007: A Practical Guide for Users, Administrators and Developers Authors: Jeff Webb, Pages: 428, Published: 2007
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Real World SharePoint 2007: Indispensable Experiences from 16 MOSS and WSS MVPs Authors: Robert Bogue, Adam Buenz, Scot Hillier, Andrew Connell, Stacy Draper, Luis Du Solier Grinda, Todd Klindt, Jason Medero, Dustin Miller, Shane Perran, Joris Poelmans, Heather Solomon, Nick Swan, Jan Tielens, Mike Walsh, Shane Young, Pages: 504, Published: 2007
Professional Community Server Themes Authors: Wyatt Preul, Benjamin Tiedt, Pages: 337, Published: 2007

Web:
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps Apr 11, 2006 ... master page masterpages asp.net 2.0. ... but the best approaches are the ones that use the master page for ... Text = "Custom footer text!!" ...
How to Create a SharePoint Server 2007 Custom Master Page and Page ... You can add new custom master pages to the master page gallery for the site ...... There are many approaches to develop master pages and page layouts, ...
Consistent development of Master Pages, Page Layouts and User ... ... reference your custom controls in all Master Pages, Page Layouts and User Controls in the particular Web Application! Another benefit of this approach ...
Branding SharePoint - Part 2: Creating the Design in SharePoint Your custom master page will not reach past your standard web pages and affect ..... What is the best way to approach this? I am using Sharepoint Designer. ...
Sridhar's Blog : Can I customize application.master and aspx files ... He said he followed Customizing Master Pages in Windows SharePoint Services & How to: ... if I could suggest one best approach to customer it is this: ...
SharePoint Happenings - SharePoint Blog, tips and tricks, and web ... Sep 8, 2008 ... Consolidating Master Pages Customized By SP Designer ... The best approach to this is to use a feature that you can activate on the sites ...
Customizing Application.master « Greg Galipeau’s Weblog Jun 19, 2008 ... I often show people how to create custom site definitions with custom masterpages for their SharePoint sites. And, every time the dreaded ...
Tomblog » Master Pages Now, the strange thing is, the custom master pages of MOSS (BlueBand, OrangeSingleLevel, … ..... This was my global approach for custom SharePoint branding. ...
ASP.NET Master Pages Tips and Tricks The downside of this approach is that any custom controls defined in a concrete master page class won't be accessible through Intellisense™ and will have to ...
Master Pages: Master Your Site Design with Visual Inheritance and ... As mentioned earlier, the implementation of Master and Content Pages is quite similar to the approach taken by many developers building their own custom ...

Videos:
Using ROSE to Mitigate Performance Trade-offs Google TechTalks April 03, 2006 Daniel Quinlan ROSE is a tool for building source-to-source transformation tools for the optimization of C and C++ ...
www.moldytoaster.com ality of the Paphian paragon; and Stultz, with his grace-bestowing shears, has fashioned West of England broad-cloths, and fancy goods, into all the ...
www.moldytoaster.com , but the executioner. As he thus reflected, he felt the sensation we have described, and which had hitherto been unknown to him, arise in his bosom...
www.moldytoaster.com re in a galaxy to some provincial Belle Vue-terrace or Prospect-place; where they endeavour to forestall the bachelors with promiscuous orange-blosso...
www.moldytoaster.com rasting so strongly with those of his neighbours to the east and west: of whom the Ghorkas are brave and warlike to a proverb, and the Bhotanese quar...




Search This Site:










dnn + catalook site

deployment

controls working on development machine, not working on server

how to dynamically load web user control

webproject reference in class lib

using the dnn utilities.calendar class

another impersonation problem - creating a reusable function

clarification needed on the discussions and feedback module

hosting more than 1 dnn site with a godaddy deluxe hosting account

disappearing menu

locked out of portal login - dnn 3.2.2

how can i refresh dnn's cache?

looking for orange futurism skin

new install at webhost4life

question password

creating user control that allow literal content

how to build application.exe

security of folder

loading pages and data access

pain with panes

compilation error cs0030: cannot convert type 'masterpage.masterpage' to 'asp.masterpage_masterpage_master'

problem: onitemcommand on datagrid causes error in module

create new portal in dnn 3.0.4

where is styles.css in visual studio 2005 webapp?

windows password popup problem

treeview efficiency

urgent help needed!!

how to check the username with active directory and fetch the user details from the active directory?

new module - defmatchgame

need some help on an error in datagrid paging (code in post)

 
All Times Are GMT