Assembly: System.Web (in system.web.dll)
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.
|Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web Developer||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|
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.
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.