Export (0) Print
Expand All

Content Class

Note: This class is new in the .NET Framework version 2.0.

Holds text, markup, and server controls to render to a ContentPlaceHolder control in a master page.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public class Content : Control, INamingContainer
public class Content extends Control implements INamingContainer
public class Content extends Control implements INamingContainer

A Content control is a container for the content and controls of a content page. A Content control is used only with a master page that defines a corresponding ContentPlaceHolder control. A Content control is not added to the control hierarchy at runtime. Instead, the contents within the Content control are directly merged into the corresponding ContentPlaceHolder control.

The Content control is associated with a ContentPlaceHolder using its ContentPlaceHolderID property. Set the ContentPlaceHolderID property to the value of the ID property of a ContentPlaceHolder control in a master page. When the URL of the content page is called, all text, markup, and server controls that are contained within the Content control are rendered to the ContentPlaceHolder on the master page, and the address bar of the browser will show the name of the content page.

For more information about master pages and content pages, see ASP.NET Master Pages Overview.

TopicLocation
Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web DeveloperBuilding ASP .NET Web Applications in Visual Studio
How to: Create Content Pages for an ASP.NET Master Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio

The following code example shows how to use the Content control to define the content for a master page. The first Web page is a master page and defines a content region using a ContentPlaceHolder control.

<%@ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>MasterPage Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />
    </div>
    </form>
</body>
</html>

The following code example demonstrates how to use a content page for the preceding master page. The text, markup, and any server controls that are defined within the Content control template are rendered to the ContentPlaceHolder on the master page.

<%@ Page Language="C#" MasterPageFile="~/MasterPageSample_1cs.master" Title="Content Page"%>

<asp:content 
    runat="server"
    contentplaceholderid="ContentPlaceHolder1" >Hello, Master Pages!</asp:content>

  • AspNetHostingPermission  for running the Content control in a hosted environment. Associated enumeration: Minimal
  • AspNetHostingPermission  for running the Content control in a hosted environment. Associated enumeration: Minimal

System.Object
   System.Web.UI.Control
    System.Web.UI.WebControls.Content

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft