2

guys i have a css file "menu.css" i called it in the head of my master page but it does not seem to work.

  <link href="CSS/menu.css" rel="stylesheet" type="text/css" />

i tried many alternatives such as

 <link id="Link1" href='<%= ResolveUrl("~/CSS/menu.css") %>' rel="stylesheet" media="screen" type="text/css"/>

But all to no avail. However when i paste the content of the css in the master page head there by eliminating the css file, it then works. I really don't understand what the error is. All seem ok but it is not doing as expecteed. Below is my Master page. Any help would be appreciated.

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Debt.master.cs" Inherits="Debt.Debt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <link id="Link2" href='<%= ResolveUrl("~/CSS/menu.css") %>' rel="stylesheet" media="screen" type="text/css"/>
    <title>Members Page</title>
    <asp:ContentPlaceHolder ID="head" runat="server">



    </asp:ContentPlaceHolder> 


    <style type="text/css">

        * { margin:0;
    padding:0;
}
body { background:#555 url(images/back.jpg); }
#menu { top:30px; }
#copyright {
    margin:100px auto;
    width:80%;
    font:12px 'Trebuchet MS';
    color:#bbb;
    text-indent:20px;
    padding:40px 0 0 0;
}
#copyright a { color:#bbb; }
#copyright a:hover { color:#fff; }



        .style1
        {

        }

            .ModalBackground  
            {  
                  background-color:Gray;  
                  filter: alpha(opacity=60);  
                  opacity: 0.6;  
                  z-index: 10000;  
            }  

            .ModalPopup  
            {  
                  background-color:White;  
                  border-width:3px;  
                  border-style:solid;  
                  border-color:Gray;  
                  padding:5px;  
                  width: 350px;  
                  height:210px; 
            }  
    </style>
     <link id="Link1" href='<%= ResolveUrl("~/CSS/menu.css") %>' rel="stylesheet" media="screen" type="text/css"/>
    <link href="CSS/menu.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <script type="text/javascript" src="scripts/menu.js"></script>
</head>

<body runat="server">
9
  • What is the structure of your files? Commented Sep 10, 2013 at 6:59
  • Is there any error in your console? Please check your path specified Commented Sep 10, 2013 at 6:59
  • Nope there is none. Moreover, when i paste the style in the header instead of calling the file, it works. I am confused why calling css file isn't working? Commented Sep 10, 2013 at 7:02
  • inspect the css link in chrome and see what is the error in path Commented Sep 10, 2013 at 7:02
  • Check whether you css file in included in project.If not then include it. Commented Sep 10, 2013 at 7:05

2 Answers 2

2

Thanks guys for all the help. I figured what the error was. It was the images path form the CSS. i called the images as follows

 background:url(images/columns.png) no-repeat;
background:url(images/subitem.png) no-repeat;

For some reason, it does not recognizes the above images path. However when i changed to

background:url(/images/columns.png) no-repeat;
background:url(/images/subitem.png) no-repeat;

That is adding a slash before the folder name. It works fine now. Thanks for your time.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are using Visual Studio 2012 you can simply drag any CSS or JS file from the solution browser into your HTML document, and the editor creates the link statement for you. I personally prefer this approach as it eliminates the chance of path errors.

Hope that helps!

4 Comments

thanks. Thats how i do mine as well. i did many and all are working except this one.
Have you tried to use a developer tool in Chrome/Firefox/IE to see if the CSS file is actually loaded? Also, remember that browsers usually cache CSS/JS files, so Ctrl+R or F5 could load recent changes.
when i inspect on chrome, i can view my css and therefore i prusumed its loaded. But it still does not seem to work.
Okey, now I am just guessing: Could it be that the runat=server in the head tag has something to do with it? After all, the css should be run on the client, not the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.