Understanding Master Pages

SharePoint uses the master page concept to achieve a uniform look and feel across a site, and you will find yourself extensively working with master pages in SharePoint.


Did You Know?

Master pages were introduced in ASP.NET 2.0 and allow you to create a consistent layout for the pages in your site.


A master page defines user interface elements common across the site. In addition it defines content placeholders that can be overridden by the individual pages to achieve the user interface specific to the pages. This allows you to have a consistent look and feel across the site. You can use a single master page for the entire site or use multiple master pages. You can also have nested master pages. All this gives you a lot of flexibility to achieve the desired look and feel.

SharePoint 2010 comes out of the box with a few master pages. The default master page used by SharePoint 2010 is v4.master. This will be the master page you use most. It provides the ribbon bar and all the other new visual UI changes such as the Site Actions menu on the left side.

Then there is the default.master, which is similar to the default.master in SharePoint 2007. This master page renders the look and feel of SharePoint 2007 and will be used by sites that have upgraded from SharePoint 2007 to SharePoint 2010 and want to use the old user interface.

The search pages and the Office web applications use minimal.master. This is a really slimmed down master page with next to nothing on it.

There are also the mwsdefault.master and the mwsdefaultv4.master, which are used by the meeting workspaces.

You can find these master pages at the <14 Hive>TEMPLATEGLOBAL directory.

Let’s now look at the structure of the SharePoint master page. If you open the v4.master you find the following:

• Various tag prefixes registered at the start. These are required for the various controls used in the page.

• Various SharePoint controls declared in the head section. These are required to include the CSS and JavaScript files required by the SharePoint site.

• You find the ScriptManager tag immediately after the forms tag. SharePoint 2010 now supports AJAX.NET out of the box.

• A SPWebPartManager is declared after the ScriptManager tag.

• Many ContentPlaceHolders. Most of the content placeholders are overridden by the individual pages. When creating your own custom master page you might add new ContentPlaceHolders or remove some. There are a few required ContentPlaceHolders that must always be present in your master page. These are listed in Table 6.1.

Table 6.1. Required Content Placeholders in a SharePoint Master Page

Image
Image
Image

In addition to those listed in Table 6.1, the following content placeholders are not part of the user interface but are used for backward compatibility:

<asp:ContentPlaceHolder id="PlaceHolderPageImage" runat="server"/>

<asp:ContentPlaceHolder id="PlaceHolderTitleLeftBorder" runat="server">

<asp:ContentPlaceHolder id="PlaceHolderMiniConsole" runat="server"/>

<asp:ContentPlaceHolder id="PlaceHolderTitleRightMargin" runat="server"/>

<asp:ContentPlaceHolder id="PlaceHolderTitleAreaSeparator" runat="server"/>

<asp:ContentPlaceHolder id="PlaceHolderNavSpacer" runat="server">

<asp:ContentPlaceHolder id="PlaceHolderLeftNavBarBorder" runat="server">

<asp:ContentPlaceHolder id="PlaceHolderBodyLeftBorder" runat="server">

<asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server">

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.182.45