0

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

2 Answers 2

1

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 :)

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

2 Comments

Drag the CSS file from Solution Explorer into the head tag in code view ;-)
Just did it. The problem was that the user had no permission to access the css folder ;)
0

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.

1 Comment

Well this is a different thing. Path without a leading slash means relative path. If you are currently in, say, foo.bar/Products/Default.aspx then it will look for Landing.css in the directory foo.bar/Products/css/Landing.css. If there is a leading slash it means an absolute path and will follow foo.bar/css/Landing.css no matter what is the current location. The latter, i.e. with a leading slash is much more preferable.

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.