Thursday, February 10, 2011

Link to CSS directory with ~

I have a CSS link that looks like this:

<link href="../../css/WW/parts.css" type="text/css" rel="stylesheet" />

But now I want the CSS directory not to be linked to as "../../", but as "~/", i.e from the top of the project.

So I changed the CSS call to:

<link href="~/project/css/WW/parts.css" type="text/css" rel="stylesheet" />

But what happens is that the path is added to the current paht, instaed of going to the top of the project:

http://localhost:3333/Project/Apps/WW/~/project/css/WW/parts.css

What am I doing wrong? What's the right way to go about this?

  • Normally, "top of project" means the document root. If you're trying to do that, try:

     <link href="/project/css/WW/parts.css" type="text/css" rel="stylesheet" />
    

    If not, start pathing to the CSS from whatever directory / uses.

    From thedz
  • AFAIK ~ is for the server to resolve the URL. If you wan't this, then you need to add runat="server" to the link element. [Edit] Seems that you don't need runat="server", the server will resolve ~ by itself, giving you the "../../path".

    A better solution would be "/css/WW/parts.css" :)

    From cwap

0 comments:

Post a Comment