ASP.NET Syntax ASP.NET Syntax for Web Controls
Defines a region for content in an ASP.NET master page.
Declarative Syntax
<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 = "True | False">
<!-- child controls -->
</asp:ContentPlaceHolder>
For information on the individual members of this class, see ContentPlaceHolder in the class library.
A ContentPlaceHolder control specifies a place or a section in a master page, to hold the contents of an associated Content control.
A master page can have one or more <asp:contentplaceholder
> controls.
To associate a Content control to a ContentPlaceHolder in a master page, the Content control’s ContentPlaceHolderID property is set to the value of the ID property of the ContentPlaceHolder control.
NOTE: While a single .aspx content file can have one or more <asp:content
> controls, only one Content control can be associated for each <asp:contentplaceholder
> control in the linked master page.
This site is an actual example of using master pages. This page is actually made up of Content controls, which in turn make up the content of <asp:contentplaceholder> controls defined in the master page file. To see how this page and its master page is done, click here.
Notice that there is no reference to the master page file on this page. This is because references to the master page files used on this site are stored in web.config files that cover different subsections of this site.
<configuration>
<system.web>
<pages masterPageFile = "~/aspnet/aspnet.master" />
</system.web>
</configuration>
This way, any file ( that includes <asp:content> controls ) within the application boundary covered by the web.config file, automatically use the referenced master page file.
ContentPlaceHolder Class