links and master pages

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
 
C

Chris Fulstow

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
 
G

George Ter-Saakov

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
 
B

Bryce

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...
 
B

Bryce

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
 
B

Bryce

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top