JSBach
JSBach

Reputation: 4747

CSS in an external file not being applied

I've read some similar issues here, but no answer they provided could help me.

I have a small asp.net page for study porpuses:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 

Inherits="Site.Default" %>
<!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">
    <title></title>
    <link rel="Stylesheet" type="text/css" href="/css/Landing.css" />
</head>
<body>
    <form id="form1" runat="server">
    <div id="loginHeader" class="aaa">
        <div>
            <asp:TextBox ID="txtUsername" runat="server"/>
            <asp:TextBox ID="txtPassword" runat="server"/>
            <asp:Button ID="Button1" runat="server" Text="Login" OnClick="btnLogin_Click" />
            <asp:Button ID="Button2" runat="server" Text="Register" OnClick="btnRegister_Click" />
            <br />
            <asp:Label ID="Label1" runat="server" Text="Password not valid" Visible="False"/>
        </div>
    </div>
    </form>
</body>
</html>

As you can see, the css/landing CSS file is being added. Here is this css file:

#loginHeader 
{
display:block;
background-color:Blue;
}

.aaa
{
    display:block;
    background-color:Red;
}

If I open the page, no style is applied. Firebug shows that the css is being downloaded. If I move the css markup to the page, inside a tag, it works, if I change back to the css file, it stops working.

Do you see any reason for this behavior?

Thanks, Oscar

Upvotes: 0

Views: 1057

Answers (2)

Vikas
Vikas

Reputation: 354

You have written the link tag this way.

<link rel="Stylesheet" type="text/css" href="/css/Landing.css" />

Make it

<link rel="Stylesheet" type="text/css" href="css/Landing.css" />

This will instruct the browser to look for the "Landing.css" file inside the css directory.

Upvotes: 0

JSBach
JSBach

Reputation: 4747

I Just found it out: there was an error on my config file, which defined that the user should be logged in to access the css files... solved, thanks :)

Upvotes: 1

Related Questions