Home > Articles > Web Development

  • Print
  • + Share This
This chapter is from the book

Creating a Master and Content Page

A Master page is a special type of ASP.NET page that allows you to share contents, such as graphics, HTML code, and ASP.NET controls, between pages. Master pages are similar to Dynamic Web Templates because they share elements between pages. However, Master pages add the ability to share code. If you have ASP.NET 2.0 available on your Web server, you can take advantage of Master pages. A Master page uses content controls instead of editable regions in a Dynamic Web Template. The content control on the Master page (ContentPlace Holder) maps to the content control on the Content page (Content). After you create a Master page using a template in the New dialog box, you need to save it with the .master file extension. Now, you can create a Content page and link it to a Master page.

Create a Master Web Page

  • yelllow01.jpg Click the File menu, point to New, and then click Page.
  • yelllow02.jpg In the left pane, click General or ASP.NET.
  • yelllow03.jpg Click Master Page.
  • yelllow04.jpg Click OK.

    An Untitled_1.master page appears in the Editing window.

  • yelllow05.jpg Click the File menu, and then click Save As.
  • yelllow06.jpg Type a name for the master page.
  • yelllow07.jpg Click the Save as type list arrow, and then click Master Page.
  • yelllow08.jpg Click Save.

Create a Content Web Page

  • yelllow01.jpg Click the File menu, point to New, and then click Page.
  • yelllow02.jpg In the left pane, click General or ASP.NET.
  • yelllow03.jpg Click Create from Master Page.
  • yelllow04.jpg Click OK.
  • yelllow05.jpg Click the Specific Master Page option.
  • yelllow06.jpg Click Browse, locate and select the master page, and then click Open.
  • yelllow07.jpg Click OK.

    An Untitled_1.aspx content page appears in the Editing window.

    The Content page pulls in the content from the Master page in the ControlPlaceHolder control.

  • yelllow08.jpg Click the File menu, and then click Save As.
  • yelllow09.jpg Type a name for the content page.
  • yelllow10.jpg Click the Save as type list arrow, and then click Web Pages.

    This saves the content page with the .aspx extension.

  • yelllow11.jpg Click Save.
  • + Share This
  • 🔖 Save To Your Account