Creating A Master Page

In this section you will add a Master Page to your project, format it, and then add one of the new ASP.NET 2.0 navigational control's to it.

1.  Add a Master Page to your project just as you would any other new item.  In the Solution Explorer, right-click the project and select Add New Item.  In the Add New Item dialog select Master Page, and then click Add.


VB

On the design surface of the Master Page you are going to add an HTML table for positioning some of the controls on the page.  When switching to the design surface, you will notice that a ContentPlaceHolder control has already been placed on the Master Page. The content of pages that use this Master Page is placed in this ContentPlaceHolder control. You will see how this all comes together when you reference the Master Page from an ASPX page.

2.  Below the Code Editor window click Design. Select the Layout | Insert Table menu command. In the Insert Table dialog select Template. From the Templates menu select Header and side, and then click OK.

3.  Place your cursor in the lower right cell of the table, and then press F4. In the Properties window, for VAlign select top. Drag the existing ContentPlaceHolder control into this cell. Add an "Authors" header (H1) to the top cell, and then click and drag the bottom border of this cell to shorten its height. The final layout should look like this:

4. Click into the lower left cell and press F4. In the Properties window, for VAlign select top.

5. From the Toolbox drag a Menu control onto the design surface, placing it in the lower left cell.

6. For Choose Data Source select <New data source...>. In the Data Source Configuration Wizard select Site Map. Change the default ID to "menuSiteMapDataSource", and then click OK.

 

This site map data source is an XML file called Web.sitemap that must reside in the root of your Web site. It contains the navigation menu hierarchy. You will be editing it in the next lesson.

7.  Finally, give the ContentPlaceHolder control a more meaningful ID. In its Properties window change (ID) to "bodyContentPlaceHolder".

 
HyperLink HyperLink

Powered By ASP.NET v2.0