Relative URL

A

Alan Roberts

Hi

How do I refernece links so that they work on both my development and live
servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my
live server doesn't work (because it points back to the root of my website,
not that of my virtual directory)?

Cheers

Alan
 
S

Saber

It works for me both in server-side and my IIS on pc:
<img src='images/image1.gif'>
remove the first "/" and try again, if you've images folder in one level
upper than your files, it works.

Another thing, perhaps you didn't added the file to your project.
if you use visual studio:
select your "images" folder in solotion explorer, right-click|Add|Existing
Item , and then choose your images you want to add to yout project.
 
A

Alan Roberts

Hi Saber

Thanks for the advice but this doesn't work for controls etc. I have a
number of controls that use graphics. These controls can occurr on pages at
any level within my site so the relative path to the images folder from them
is different. I need some way to indicate paths relative to the application
root rather than the web server route.

Cheers

Alan
 
B

Bob Lehmann

Use "~". ~/images/image1.gif

You will have to use server tags though. Or perhaps the ResolveURL method.

Bob Lehmann
 
A

Alan Roberts

Thanks guys. This seems to work got img tags as well as long as i include
runat=server in them. Is there a similar shortcut that can use within CSS
files?

Alan
 

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

Top