Customizing WSS 3.0 with Master Pages
page 2 of 14
by Ameet Phadnis
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 61019/ 123

Basics of Master Pages

In ASP.NET 2.0, Microsoft introduced the concept of Master Pages. Master Pages are a common base file that provides consistent layout across multiple pages in your application. You can have a single Master Page or multiple Master Pages in your application. To use Master Pages in your application, you create a Master Page with the extension .master. This Master Page will hold the site layout and design. The next step will be to create multiple content pages based on the Master Page. On the Master Page you need to define the content server control. The definition of the content server control looks like the following.

Listing 1

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" 

This content place holder will hold the controls that are specific to the content pages. You can have single or multiple content place holders.

When you create new Content Pages, you can either specify the MasterPageFile attribute on the page or you can specify it in the Web.Config file. In Content Pages your attribute will look like:

Listing 2

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" 
    Inherits="ReportsApp._Default" MasterPageFile="~/ReportingApp.Master"%>

In Web.Config file it will look be:

Listing 3

  <pages masterpagefile="~/ ReportingApp.master"> 

If we just have one Content Place holder then the page will be designed as follows.

Listing 4

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" 
    Inherits="ReportsApp._Default" MasterPageFile="~/ReportingApp.Master"%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" 

If you would like to dynamically assign the Master Page file then it has to be done in the Page_PreInit event.

Listing 5

MasterPageFile ="~/ReportingApp.Master"

Any item that is specific to this page goes inside the Content Place holder. You can have multiple Content Place holder controls on your page with different ID's. If you need more information on Master Pages you can review various articles by searching on Master Pages in

View Entire Article

User Comments

Title: Edward   
Name: Logo Design
Date: 2012-07-06 4:10:56 AM
I am impressed by the quality of information on this website. There are a lot of good resources here. I am sure I will visit this place again soon
Title: ExternalLInks display   
Name: Sam
Date: 2010-04-18 12:22:10 PM
I was wasting sometime when i found something which most of us will tend to make mistake on:
Title: Any way to use Cascading Master pages   
Name: Diwakar
Date: 2008-09-05 5:05:33 PM
Is there a way to use Cascading Master pages? The scenario i have is - the root site will have the default master page, the sub site should be able to use their own Master page. I don't want to copy all the contents from the default Master Page and copy it into the Sub site's master page and then add the new stuff. Rather i want to leave the common stuff in the default master page and create the Sub Site master page with new stuff only. And when a page from the Sub site is rendered it uses the combination of two master pages.
Is this possible??
Title: And for wss v3?   
Name: Omar Damiani
Date: 2008-05-02 8:56:04 AM
But this works only for MOSS 2007, for wss v3 what do you have to do to create/add a new Master Page?

For wss v3 in the Site Settings you don't have "Master Page" voice in the "Look and Feel" menù (as explained in the "Assigning your Master Page to your site" section of this article...)
Title: great article   
Name: klibey
Date: 2008-04-25 11:32:50 AM
you mentioned in the part about adding the sitemap provider to the web.config file...

this makes sense, the only thing I am wondering is
where would I drop my sitemap file at?

Thanks for the excellent resource,

Title: WSS or Moss   
Name: Manuelito
Date: 2007-09-06 7:51:00 AM
I think it's about master pages for WSS and MOSS (because you show us snapshots of moss publishing sites)

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-23 6:14:45 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search