Solved

content place holder in head section of the master page

Posted on 2010-08-17
6
766 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

24 Experts available now in Live!

Get 1:1 Help Now