eran otzap
eran otzap

Reputation: 12533

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" />

Upvotes: 1

Views: 1764

Answers (3)

eran otzap
eran otzap

Reputation: 12533

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>

Upvotes: 1

pheoke
pheoke

Reputation: 31

I'm not sure you can use the tilda ~ for the path in the link. I think the tilda(~) is a .net shortcut, and since your just rendering html the browser won;t know where to look.

Upvotes: 1

Guffa
Guffa

Reputation: 700342

You can only use the ~ root specifier in server controls, the browser doesn't understand that URL, and doesn't know where your application root is either even if it would.

Put runat="server" in the link tag, or use an URL that is relative to the site root:

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

Upvotes: 1

Related Questions