Export (0) Print
Expand All

Create a master page

When you create a master page, you can lay it out, apply styles, and add ASP.NET controls in the same way that you would with other pages in Microsoft Expression Web. The layout and content you create in a master page are applied to pages attached to the master page.

To create a new master page

  1. On the File menu, click New, and then click Page.

  2. In the Page tab of the New dialog box, select General or ASP.NET in the leftmost list and Master Page in the center list.

  3. Set the default programming language for your master page in the Programming Language drop-down box in the Options area.

  4. Click OK.

    Your new master page will open in the editor. When you save the file, make sure to keep .master as the file name extension.

    By default, when you create a new master page it contains two content placeholder controls: HEAD, and ContentPlaceHolder1.

Default content placeholders

If you want to add to, remove, or modify content placeholder controls, you must have one or more content placeholder controls on your master page. Anything inside the content placeholder control tags can be edited in pages based on your master page. Everything else in the master page is not editable in the content pages.

<asp:contentplaceholder id="head" runat="server">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
tip noteTip

Make sure that you put all your layout content (tables or divs) outside the content placeholders.

For example, the style sheet link in the following master page header is outside the content placeholder, so it will be applied to all pages based on the master page and cannot be changed in individual content pages. If the style sheet link tag were inside the content placeholder, it would still apply, but could be changed in the content pages.

NoteNote

Do not remove the head content placeholder. Expression Web uses this content placeholder to include styles you interactively design. If you remove the head content placeholder, Expression Web will create inline styles rather than style classes when you style elements in content pages. Also, if you remove the head content placeholder, you will not be able to set properties in content pages through the Page Properties dialog box.

To add content placeholders to a master page

  1. In Design view, right-click the page and click Manage Microsoft ASP.NET Content Regions on the shortcut menu.

  2. In the Manage Content Regions dialog box, type the name of the new region in the Region name box.

  3. Click Add.

To add content placeholders on a master page by using code

  • In Code view, type the following, providing a unique value for ID:

    <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
    </asp:contentplaceholder>
    

To delete content placeholders from a master page

  1. In Design view, right-click the page and click Manage Microsoft ASP.NET Content Regions on the shortcut menu.

  2. In the Manage Content Regions dialog box, select the content placeholder you want to delete.

  3. Click Remove.

To delete content placeholders from a master page by using code

  • In Code view, delete the <asp:contentplaceholder> and </asp:contentplaceholder> tags.

To rename content placeholders on a master page

  1. In Design view, right-click the page and click Manage Microsoft ASP.NET Content Regions on the shortcut menu.

  2. In the Manage Content Regions dialog box, double-click the content placeholder you want to rename.

  3. In the Region Name box, type the new name.

  4. Click Rename.

To rename content placeholders on a master page by using code

  • In Code view, change the value of the ID attribute in the <asp:contentplaceholder> tag.

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show:
© 2014 Microsoft