1

I am working on a page which is using a Master page for some default design, I need some css class to be added to the conent page, which we add normally in script tag in normal pages, My question is how to add some css content in a page which is using Master page,

Thanks, Vishal.

2 Answers 2

5

In your master page you can add a content area within the <head> block. We call ours "HeadContent".

Our master page's head block looks like this:

<head>
    ...
    <asp:ContentPlaceHolder ID="HeadContent" runat="server" />
</head>

From your content pages you can then include custom scripts/css etc:

<asp:Content runat="server" ID="Head" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript" src="<%= Url.Content("~/scripts/gradebook.js") %>"></script>
    <style type="text/css">
        @import url('<%= Url.Content("~/styles/gradebook.css") %>');
    </style>
</asp:Content>
Sign up to request clarification or add additional context in comments.

Comments

1

You could add a ConentPlaceHolder in the head area of your masterpage like this:

<head>
 ....
<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
</head>

In your content page you just need a content control:

<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="Server"> 
   // Put your css stuff here
</asp:Content>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.