Solved

content place holder in head section of the master page

Posted on 2010-08-17
6
811 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

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
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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