Solved

content place holder in head section of the master page

Posted on 2010-08-17
6
804 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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