Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Working in a new web application created in vs2010.

I have noticed a tag in the master page and webform page.Pls explain what is the exact usage of this.

In masterpage:

ASP.NET
<head>
<asp:ContentPlaceHolder id="head" runat="server">

</head>


In webform:

ASP.NET
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
Posted
Updated 15-Nov-11 22:10pm
v2
Comments
Kamlesh Saini 2022 11-Jun-22 6:41am    
1990

Master pages are meaned to use with Content (Webforms) pages.

So, when you create a master page, You will have to fix a place where the child page (content page) will be incorporated. hence you will put some ContentPlaceHolder inside your master page, you can put them in either head or body part of the page.

every html page can have only single html,head,body,etc. tags, so if you are using master page you will put this tgs in master page so child page can not have any of this tage once gain. you can put only
ASP.NET
<asp:content />
tags.

when you are creating a Webform (content page), and assinging a master page to it. you have to specify where this form will reside in master page. so you have to select a ContentPlaceHolder id.


mark as answer if satisfied with the solution, it motivates :)
 
Share this answer
 
v3
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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900