views:

41

answers:

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?

+1  A: 

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.

Anthony Pegram
+2  A: 

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>
codemeit