2

I have a CSS stylesheet defined in the Master Page of my project. On one of the pages/views that inherits from the Master Page, I need to add another CSS stylesheet (I could also add it inline, though I'd rather not).

However, how to do this escapes me. Is this even possible?

2 Answers 2

2

In your master page, you can have

<!-- in Master Page  --> 
<head runat="server">
    <link href="Style.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="header" runat="server">
    </asp:ContentPlaceHolder>
</head>

In your view page, you can add more into the header,

<!-- in view Page -->  
<asp:Content ID="viewContent" ContentPlaceHolderID="header" runat="server">
    <link href="Style1.css" rel="stylesheet" type="text/css" />
</asp:Content>

The final page will be rendered as

<head runat="server">
    <link href="Style.css" rel="stylesheet" type="text/css" />
    <link href="Style1.css" rel="stylesheet" type="text/css" />
</head>
Sign up to request clarification or add additional context in comments.

Comments

1

The header area of the master page can include a ContentPlaceHolder control. The child page can utilize this control to specify scripts or stylesheets to be consumed by the child. The contents of this place holder can obviously vary from child to child and is obviously not required to be used.

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.