Css not getting applied

My web app directory structure is like

Root-Masterpagebook.master
Root-Chapter1/page1.aspx
Root-Chapter2/page2.aspx
Root-CSS/styles.css

in my master page i have linked my stylesheet like this

 <link  type="text/css" rel="stylesheet" media="all" href='<%= ResolveUrl("~/CSS/styles.css") %>'/>

it only works when i  remove my master page head elements runat=server attribute. Is there any fix for this problem. If i  keep the runat=server attribute I see this in viewsource for my stylehsheet

<link href="../<%= ResolveUrl("~/CSS/styles.css") %>" media="all" rel="stylesheet" type="text/css">
It does have css tree linked but it won't apply

Any ideas why
mmalik15Asked:
Who is Participating?
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hello,why not just:
<link  type="text/css" rel="stylesheet" media="all" href="CSS/styles.css"/>
0
 
mmalik15Author Commented:
It does not work. Tried that in the first place. Also i need to change the master page programatically at run time.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Your master page head element looks like this?
<head runat="server">
    <title></title>
    <link href="CSS/styles.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.