Content Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Holds text, markup, and server controls to render to a ContentPlaceHolder control in a master page.
public ref class Content : System::Web::UI::Control
public class Content : System.Web.UI.Control
type Content = class
inherit Control
interface INamingContainer
Public Class Content
Inherits Control
- Inheritance
- Implements
Examples
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>
<%@ Page Language="VB" MasterPageFile="~/MasterPageSample_1vb.master" Title="Content Page"%>
<asp:content
runat="server"
contentplaceholderid="ContentPlaceHolder1" >Hello, Master Pages!</asp:content>
Remarks
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.
Declarative Syntax
<asp:Content
ContentPlaceHolderID="string"
EnableViewState="True|False"
ID="string"
runat="server">
Visible="True|False"
<!-- child controls -->
</asp:Content>
Constructors
| Name | Description |
|---|---|
| Content() |
Initializes a new instance of the CompositeDataBoundControl class. |
Properties
| Name | Description |
|---|---|
| Adapter |
Gets the browser-specific adapter for the control. (Inherited from Control) |
| AppRelativeTemplateSourceDirectory |
Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control. (Inherited from Control) |
| BindingContainer |
Gets the control that contains this control's data binding. (Inherited from Control) |
| ChildControlsCreated |
Gets a value that indicates whether the server control's child controls have been created. (Inherited from Control) |
| ClientID |
Gets the control ID for HTML markup that is generated by ASP.NET. (Inherited from Control) |
| ClientIDMode |
Gets or sets the algorithm that is used to generate the value of the ClientID property. (Inherited from Control) |
| ClientIDSeparator |
Gets a character value representing the separator character used in the ClientID property. (Inherited from Control) |
| ContentPlaceHolderID |
Gets or sets the ID of the ContentPlaceHolder control that is associated with the current content. |
| Context |
Gets the HttpContext object associated with the server control for the current Web request. (Inherited from Control) |
| Controls |
Gets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy. (Inherited from Control) |
| DataItemContainer |
Gets a reference to the naming container if the naming container implements IDataItemContainer. (Inherited from Control) |
| DataKeysContainer |
Gets a reference to the naming container if the naming container implements IDataKeysControl. (Inherited from Control) |
| DesignMode |
Gets a value indicating whether a control is being used on a design surface. (Inherited from Control) |
| EnableTheming |
Gets or sets a value indicating whether themes apply to this control. (Inherited from Control) |
| EnableViewState |
Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client. (Inherited from Control) |
| Events |
Gets a list of event handler delegates for the control. This property is read-only. (Inherited from Control) |
| HasChildViewState |
Gets a value indicating whether the current server control's child controls have any saved view-state settings. (Inherited from Control) |
| ID |
Gets or sets the programmatic identifier assigned to the server control. (Inherited from Control) |
| IdSeparator |
Gets the character used to separate control identifiers. (Inherited from Control) |
| IsChildControlStateCleared |
Gets a value indicating whether controls contained within this control have control state. (Inherited from Control) |
| IsTrackingViewState |
Gets a value that indicates whether the server control is saving changes to its view state. (Inherited from Control) |
| IsViewStateEnabled |
Gets a value indicating whether view state is enabled for this control. (Inherited from Control) |
| LoadViewStateByID |
Gets a value indicating whether the control participates in loading its view state by ID instead of index. (Inherited from Control) |
| NamingContainer |
Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value. (Inherited from Control) |
| Page |
Gets a reference to the Page instance that contains the server control. (Inherited from Control) |
| Parent |
Gets a reference to the server control's parent control in the page control hierarchy. (Inherited from Control) |
| RenderingCompatibility |
Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with. (Inherited from Control) |
| Site |
Gets information about the container that hosts the current control when rendered on a design surface. (Inherited from Control) |
| SkinID |
Gets or sets the skin to apply to the control. (Inherited from Control) |
| TemplateControl |
Gets or sets a reference to the template that contains this control. (Inherited from Control) |
| TemplateSourceDirectory |
Gets the virtual directory of the Page or UserControl that contains the current server control. (Inherited from Control) |
| UniqueID |
Gets the unique, hierarchically qualified identifier for the server control. (Inherited from Control) |
| ValidateRequestMode |
Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values. (Inherited from Control) |
| ViewState |
Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page. (Inherited from Control) |
| ViewStateIgnoresCase |
Gets a value that indicates whether the StateBag object is case-insensitive. (Inherited from Control) |
| ViewStateMode |
Gets or sets the view-state mode of this control. (Inherited from Control) |
| Visible |
Gets or sets a value that indicates whether a server control is rendered as UI on the page. (Inherited from Control) |
Methods
| Name | Description |
|---|---|
| AddedControl(Control, Int32) |
Called after a child control is added to the Controls collection of the Control object. (Inherited from Control) |
| AddParsedSubObject(Object) |
Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object. (Inherited from Control) |
| ApplyStyleSheetSkin(Page) |
Applies the style properties defined in the page style sheet to the control. (Inherited from Control) |
| BeginRenderTracing(TextWriter, Object) |
Begins design-time tracing of rendering data. (Inherited from Control) |
| BuildProfileTree(String, Boolean) |
Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page. (Inherited from Control) |
| ClearCachedClientID() |
Sets the cached ClientID value to |
| ClearChildControlState() |
Deletes the control-state information for the server control's child controls. (Inherited from Control) |
| ClearChildState() |
Deletes the view-state and control-state information for all the server control's child controls. (Inherited from Control) |
| ClearChildViewState() |
Deletes the view-state information for all the server control's child controls. (Inherited from Control) |
| ClearEffectiveClientIDMode() |
Sets the ClientIDMode property of the current control instance and of any child controls to Inherit. (Inherited from Control) |
| CreateChildControls() |
Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. (Inherited from Control) |