This documentation is archived and is not being maintained.

ContentPlaceHolder Class

Defines a region for content in an ASP.NET master page.

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

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ContentPlaceHolder : Control, 
<asp:ContentPlaceHolder />

A ContentPlaceHolder control defines a relative region for content in a master page, and renders all text, markup, and server controls from a related Content control found in a content page.

A Content control is associated with a ContentPlaceHolder using its ContentPlaceHolderID property. Set the ContentPlaceHolderID property to the value of the ID property of the related ContentPlaceHolder control in a master page. More than one ContentPlaceHolder can be declared in a master page.

Within a content page, only one Content control can supply the content for a ContentPlaceHolder in the master page. However, in each content page that uses a master page, you can have separate Content controls associated with the ContentPlaceHolder. For example, you can define the ContentPlaceHolder for the page title in a master page. For each content page that uses the master page, you can add a Content control that supplies the text and markup for the page title.


For XHtml compliance, an empty title element is created if a title has not been defined or cannot be found.

You can specify default content placed within the ContentPlaceHolder control tags, but this content is replaced by any content in an associated content page.

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

How to: Reference ASP.NET Master Page ContentBuilding ASP .NET Web Applications
How to: Reference ASP.NET Master Page ContentBuilding ASP .NET Web Applications
Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web DeveloperBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Adding Site Navigation to a Web SiteBuilding 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
How to: Reference ASP.NET Master Page Content

The following code example shows how the ContentPlaceHolder control is used to define a content region 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" "">
<html xmlns="" >
<head runat="server">
    <title>MasterPage Example</title>
    <form id="form1" runat="server">
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />

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

public class SampleMasterClass : System.Web.UI.MasterPage {
     private string sitename;     
     public string SiteName
        get {return(sitename);}
        set {sitename = value;}


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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0