Using Master Pages to Specify Default Content

In this lesson, you will learn about default content in master pages. You will also learn how to use multiple content controls in a master page and how to define default markup in the content placeholder controls.

Structure of a master page

A master page may specify default markup for ContentPlaceHolder controls. A content page can then optionally specify its markup or use default markup. A master page may contain multiple content placeholders. Many website designs contain several areas on the screen that are customized on a page-by-page basis.

As explored in the previous lesson, the master page enables you to specify content areas that the content page can use. Master pages can have multiple content areas. The nice thing is that you can specify default content for the content area. This default content can be overridden by choice.

To place the default content within any one of the content areas, it is simply put into the Content PlaceHolder server control on the master page itself. Any content page that inherits this master page also inherits the default content.

This second content creates a page with one content area coming from the master page itself in addition to other content that comes from the content page. A smart tag in VS 2012 enables you to work easily with the default content.

Create custom content

Click the control’s smart tag and select the “Create custom content” option from the menu. This makes it possible to insert your own defined content.

  • HTML
In this code snippet you placed two content placeholders on the same master page and both have different content.