Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 827
  • Last Modified:

content place holder in head section of the master page

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
TrialUser
Asked:
TrialUser
  • 3
  • 2
2 Solutions
 
ComtekCommented:
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
 
Jini Jose.Net Team LeadCommented:
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
 
TrialUserAuthor Commented:
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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
ComtekCommented:
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
 
ComtekCommented:
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
 
TrialUserAuthor Commented:
Thanks a ton for your timely, detailed explanation
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now