ContentPlaceHolder Class
Defines a region for content in an ASP.NET master page.
Assembly: System.Web (in System.Web.dll)
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class ContentPlaceHolder : public Control, INamingContainer
<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.
Note: |
|---|
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.
| Topic | Location |
|---|---|
| How to: Reference ASP.NET Master Page Content | Building ASP .NET Web Applications |
| How to: Reference ASP.NET Master Page Content | Building ASP .NET Web Applications |
| Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web Developer | Building ASP .NET Web Applications in Visual Studio |
| Walkthrough: Adding Site Navigation to a Web Site | Building 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.
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.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
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.
Note: