Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add css file to only a single page (ASP.NET master pages)

Tags:

asp.net

How can I add a css file to only a child page while using ASP.NET master pages rather then specifying them in the master?

like image 626
Zo Has Avatar asked Mar 05 '12 09:03

Zo Has


2 Answers

In the master page

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

In the specific page

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
  <link href="~/pagecssfile.css" rel="stylesheet" type="text/css" />
</asp:Content>
like image 108
Adrian Iftode Avatar answered Sep 25 '22 13:09

Adrian Iftode


You can specify it in child page inside the content as mentioned below

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<link href="Css/main.css" rel="stylesheet" type="text/css" />

scope of this css will remain for this page only

like image 40
Asif Mukhida Avatar answered Sep 25 '22 13:09

Asif Mukhida