System.Web.UI.WebControls.ContentPlaceHolder Class

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

See Also: ContentPlaceHolder Members

Syntax

[System.Web.UI.ControlBuilder(typeof(System.Web.UI.WebControls.ContentPlaceHolderBuilder))]
[System.Web.UI.ToolboxData("<;{0}:ContentPlaceHolder runat=&quot;server&quot;></{0}:ContentPlaceHolder>")]
[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.ContentPlaceHolderDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.ToolboxItemFilter("System.Web.UI", System.ComponentModel.ToolboxItemFilterType.Allow)]
[System.ComponentModel.ToolboxItemFilter("Microsoft.VisualStudio.Web.WebForms.MasterPageWebFormDesigner", System.ComponentModel.ToolboxItemFilterType.Require)]
public class ContentPlaceHolder : System.Web.UI.Control, System.Web.UI.INamingContainer

Remarks

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

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

Within a content page, only one System.Web.UI.WebControls.Content control can supply the content for a System.Web.UI.WebControls.ContentPlaceHolder in the master page. However, in each content page that uses a master page, you can have separate System.Web.UI.WebControls.Content controls associated with the System.Web.UI.WebControls.ContentPlaceHolder. For example, you can define the System.Web.UI.WebControls.ContentPlaceHolder for the page title in a master page. For each content page that uses the master page, you can add a System.Web.UI.WebControls.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 System.Web.UI.WebControls.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.

Declarative Syntax

Example

<asp: ContentPlaceHolder
    EnableViewState="True|False"
    ID="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    Visible="

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0