links and master pages

  • Thread starter Thread starter Giganews
  • Start date Start date
G

Giganews

I've got a master page, with stylesheets on it defined as such:
<link href="/css/reset-min.css" rel="stylesheet" media="all" />

problem is, I have pages in different folders that link to that master page,
so any page that's not in the same folder as the master page, don't display
the css. I've tried the following:

<link href="~/css/reset-min.css" rel="stylesheet" media="all" />

which didn't work.

This did work
<link href="<%= ResolveUrl("~/css/reset-min.css") %>" rel="stylesheet"
media="all" />
But the styles don't show up in design.

Hints/tips greatly appreciated.



Thanks

Bryce
 
I've got a master page, with stylesheets on it defined as such:
<link href="/css/reset-min.css" rel="stylesheet" media="all" />

problem is, I have pages in different folders that link to that master page,
so any page that's not in the same folder as the master page, don't display
the css. I've tried the following:

<link href="~/css/reset-min.css" rel="stylesheet" media="all" />

which didn't work.

This did work
<link href="<%= ResolveUrl("~/css/reset-min.css") %>" rel="stylesheet"
media="all" />
But the styles don't show up in design.

Hints/tips greatly appreciated.

Thanks

Bryce

Hi Bryce

Try this:
<link runat="server" href="~/css/reset-min.css" rel="stylesheet"
media="all" />

The tilde won't resolve to your application root unless it's a server-
side control.

Chris
 
I bet you are not telling us the truth..... :)
You probably refer to reset-min.css without first slash. Like
<link href="css/reset-min.css" rel="stylesheet" media="all" />


This is called relative path and it refers to the path relative you current
page location.
so for "http://www.myserver.com/folder1/page1.asp" css/reset-min.css will
refer to file "http://www.myserver.com/folder1/css/reset-min.css"


Just make sure you have it as you wrote it here... with first slash like
<link href="/css/reset-min.css" rel="stylesheet" media="all" />

then it's going to be absolute path and refer to
http://www.myserver.com/css/reset-min.css


George
 
Chris said:
Hi Bryce

Try this:
<link runat="server" href="~/css/reset-min.css" rel="stylesheet"
media="all" />

The tilde won't resolve to your application root unless it's a server-
side control.

Thanks. that worked like a charm. Should have thought to do the
runat="server" bit...
 
clintonG said:
This is an issue that is discussed at length in the forums at asp.net.

Thanks. I'd visited asp.net before, but not the forums. I'll be checking
that out from now on. Thanks
 
George said:
I bet you are not telling us the truth..... :)
You probably refer to reset-min.css without first slash. Like
<link href="css/reset-min.css" rel="stylesheet" media="all" />

That's entirely possible. I thought I had tried it with the slash in
front, but might have been incorrect.
 
Back
Top