Tuesday, September 28, 2010

Scoping Master Pages in SharePoint

Master pages provide the look and feel and standard behavior that you want for all of the pages in your site. Together with content pages, they produce output that combines the layout of the master page with content from the content page. 
Because Windows SharePoint Services is built on top of Microsoft ASP.NET 2.0, it supports master pages for defining elements that are common to all pages. You can specify all of the shared elements of your site in the master page or pages, and add content page-specific elements to content pages.

Master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.
Windows SharePoint Services pages that end users can customize—list view pages, list form pages, and Web Part Pages—are content pages that contain the content to display. When a user requests a content page, it is merged with a master page to produce output that combines the layout of the master page with the content from the content page.
All content pages share the same page structure—the global breadcrumb, site title area, top navigation, page title area, and left navigation bar. In Windows SharePoint Services, this shared page structure is moved into a master page called default.master, which is used by all content pages, including the following:
  1. default.aspx
  2. AllItems.aspx, DispForm.aspx, NewForm.aspx, and EditForm.aspx: for all lists 
  3. Upload.aspx and Webfldr.aspx: for all document libraries 
  4. Any new content pages that are created in this site
 
There are three levels to attach content pages to a master page:
  • At the page level: you can use a page directive in each content page to bind it to a master page, as in the following code example. 
  • At the application level: By making a setting in the pages element of the application's configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page. The element might look like the following. If you use this strategy, all ASP.NET pages in the application that have Content controls are merged with the specified master page. (If an ASP.NET page does not contain Content controls, the master page is not applied.)
  • At the folder level: This strategy is like binding at the application level, except that you make the setting in a Web.config file in one folder only. The master-page bindings then apply to the ASP.NET pages in that folder.

No comments: