Vishal Bhatia
Vishal Bhatia

Reputation: 31

adding css class in content pages

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.

Upvotes: 1

Views: 5485

Answers (2)

Andre Kraemer
Andre Kraemer

Reputation: 2761

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>

Upvotes: 1

Michael
Michael

Reputation: 20049

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>

Upvotes: 5

Related Questions