What is the ContentPlaceHolder in master page head? I mean how I can use it?
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jun 29, 2011, 2:26 AM EDT
If you need to include a style for a specific web form, you need to have a ContentPlaceHolder in head section of Master page.
For ex:
Master page:
<%@ Master Language="C#" %>
...
<head runat="server">
...
<asp:ContentPlaceHolder runat="server" id="headerPlaceHolder" />
head>
...
Content page:
<%@ Page Language="C#"
MasterPageFile="~/Master1.master"
Title="Foo" %>
<asp:Content ID="Content1"
ContentPlaceHolderID="headerPlaceHolder"
runat="Server">
<meta name="keywords" content="declassified information" />
<style type="text/css" media="all">
@import "wildstyle.css";
style>
<script type="text/javascript" src="foo.js">script>
asp:Content>
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Jun 30, 2011, 9:06 PM EDT
raghu v52 reputationPosted Jul 1, 2011, 2:25 AM EDT
see master page is genarally used to make ur app to make maintainable easly
if u have set of pages in which u feel the outlook will be same just controls in some parts changes then to make the maintaince easy u go for master page concept in master page u create an out look which will be static for all the pages and content place holder is the one which tell u that page in heriting the master page control will use that area for changable datacontrol which are neeed for that perticular page
for ex:
if u have the master page say masterpage.master
here in masterpage.master u will have u entire static design lay out and empty content place holder
if i have in herited the masterpage.master to default.aspx then here in default .aspx i will get on content place holder where i just need to write the set of controls specific for that page but out look willl be copied from master page which in runtime will make u to get complete page
hope it will help u
Suthish NairRank #92 · 22.8K reputationPosted Jul 1, 2011, 4:42 AM EDT
contents (asp:Content) of an associated Content control.
On a master page we can have one or more ContentPlaceHolder controls.
For more articles check Our recommended articles section on right side.