Solved

content place holder in head section of the master page

Posted on 2010-08-17
6
780 Views
Last Modified: 2013-12-17
I am wondering why there is a content place holder in the <head> section in the master page. What can I use this section for in the master page and in the page that consume this master page.
Thanks
0
Comment
Question by:TrialUser
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:Comtek
ID: 33453757
You can put lots of stuff here. Anything that would normally go in the heading section of a typical web page. Probably one of the must common things is JavaScript code. Other items that could go in there are links to stylesheets and the page title.
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33453786
if you want to add a style or javascript, and that is only usefull in a particular page, then you can add that script to that pages content head section
0
 

Author Comment

by:TrialUser
ID: 33454194
Ok, a follow up question, so in th master age when I do add a link to a style sheet, i need to put it inside the Content place holder like this or outside:

<head runat="server">
    <title></title>
   
    <asp:ContentPlaceHolder ID="head" runat="server">
    <link href="~/Styles/Main.css" rel="stylesheet" type="text/css" />
    </asp:ContentPlaceHolder>
</head>
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 2

Accepted Solution

by:
Comtek earned 500 total points
ID: 33454253
Not exactly. When adding a link to a stylesheet in the master page, do it like this:
<head runat="server">
    <title></title>
    <link href="~/Styles/Main.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>

When adding a link to a stylesheet in a child page, do it like this:
<asp:Content ID="head" ContentPlaceHolderID="head" runat="server">
    <link href="~/Styles/Main.css" rel="stylesheet" type="text/css" />
</asp:Content>

So when you are adding the stylesheet to the master page, put it outside the <asp:Content ..> tag. When adding it to a child page, put it within the <asp:Content ...> tag.
0
 
LVL 2

Assisted Solution

by:Comtek
Comtek earned 500 total points
ID: 33454272
Just as a side note, once you add the style sheet to the master page, you do not need to add it to any child pages.

The only time you would add a style sheet to a child page is if you want that specific page to have a different style sheet than all the other pages on your site.
0
 

Author Closing Comment

by:TrialUser
ID: 33454719
Thanks a ton for your timely, detailed explanation
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now