Search code examples
cssmaster-pages

css style sheet from content page


Iv'e got a content page with a link to a style sheet which I want to be specific for that page , i.e. I want the design to be specific for that page when it loads and takes its place in the contentplaceholder on the main page.

IN MY CONTENT PAGE :

  <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">  
      <link href="~/Styles/StyleSheet1.css" rel="stylesheet" type="text/css" />
  </asp:Content>

IN MY MAIN PAGE :

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

MY STYLE SHEET ~/Styles/StyleSheet1.css just for example I'll give this id to some table in my content page.

       #defualt_tbl
       {
          background-color:Gray;
       }

       <table id="defualt_tbl">

The table does not become gray , when I click viewsource in the master page the link is present in the head section.

        <link href="~/Styles/StyleSheet1.css" rel="stylesheet" type="text/css" />

Solution

  • found it !

    but i belive your answers work as well .

      <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
         <link href='<%= ResolveClientUrl("~/Styles/StyleSheet1.css") %>' rel="stylesheet"    type="text/css" />
      </asp:Content>