Export (0) Print
Expand All

Add content to a content page

Once you have created a content page, that is, a page based on a master page, you can only add content to content controls (in Code view, between the </asp:Content> and </asp:Content> tags). Anything that is not in Content controls except script blocks for server code results in an error.

You can perform any tasks in a content page that you do in an ASP.NET page. For example, you can generate content for a content control using server controls and database queries or other dynamic mechanisms.

If you include content in the content placeholder controls on the master page, those controls are, by default, locked on content pages based on the master page. When you create a page based on this master page, the content control is locked and cannot be edited.

To edit default master page content in Content controls

  1. In Design view, click the arrow button at the end of the content placeholder to show the Common Content Tasks menu, and then click Create Custom Content.

    The content area becomes visible in Code view and editable in both Design and Code view.

  2. Edit the content in the control.

To revert to default master page content

  • In Design view, click the arrow button at the end of the content placeholder to show the Common Content Tasks menu, and then click Default to Master's Content.

    The Content control is again locked.

You can set page properties and add style sheets to content pages based on master pages the same way you would work with other pages in Design view. But there are some differences in Code view.

To add a style sheet to a content page

  1. On the Format menu, click CSS Styles, then click Attach Style Sheet.

  2. In the Attach Style Sheet dialog box, specify the .css file.

    When you add a style sheet to a content page, the head content control is unlocked and becomes visible in Code view. The style sheet link is added in the head control, and you can subsequently change or delete it there if you want.

    <asp:Content id="content1" runat="server" contentplaceholderid="head">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="myCSS.css" />
    </asp:Content>
    

    If the master page includes a style sheet link inside the head content placeholder, it is visible and can be retained or deleted in the content page.

    If the master page includes a style sheet link outside of the head contentplaceholder, it is not visible in the content page but in the user's browser it will be applied to the content page in addition to the style sheet specified in the content page.

To change the title of a content page

  • Do one of the following:

    • On the File menu, click Properties. In the General tab of the Properties dialog box, type the new title in the Title box.

    • In Code view, type a new title in the title attribute of the @ Page directive:

      <%@ Page language="C#" masterpagefile="m1.master" title="New Title" %>
      

Community Additions

ADD
Show:
© 2014 Microsoft