tags:

views:

33

answers:

3

I'm working on a Web Application in Visual Studio 2008. For some reason the CSS only works properly inside visual studio. I can see the CSS inside the design view of the page. When I view the page on localhost the CSS is not being applied. This is just a very simple sample that I am working with. Only 2 pages, a master page, and a default page.

Here is the master page.

<head runat="server">
<titleFoobar</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<link id="stylemain" href="Content/Style/main.css" rel="stylesheet" type="text/css"/> 
</head>
<body>

<form id="form1" runat="server">
<table border="1">
    <tr>          
    <td><a href="Default.aspx" class="topContent">Foobar</a></td>
    </tr>
    <tr>
    </tr>
    <tr>
    <td>test</td>        
    </tr>
</table>  
</form>
</body>
</html>

Here is my CSS

.topContent {
text-align: right;
background-color: #600;
color: White;
font-size: x-large;
text-decoration: none;
font-weight: bold;
padding: 10px;
height: 50px;

}

+1  A: 

Your CSS is probably at the wrong relative path. To fix, change your link to be app relative style, like this:

<link id="stylemain" href="~/Content/Style/main.css" rel="stylesheet" type="text/css"/> 

The master page will resolve this correctly, no need for a runat="server" in this case.

Nick Craver
A: 

The problem was with IIS7 I did not check Static Content when I set it up

Aaron M
A: 

Did you change the CSS file recently? Maybe an old version of the CSS file is in the browser cache. Clear your browser cache and see if that fixes the problem.

Matt Brunell