Absolute or Relative path?

M

matthias s.

Hi there,

Say I have a domain called www.mydomain.com. In my virtual directory I've
created subfolders called 'sub1' and 'sub2'. Now in 'sub1 resides the file
'file1.aspx' and in 'sub2' resides the image 'img1.jpg'. When specifying a
relative URL (to the image) in the file1.aspx I'd go like:

<img src="../sub2/img1.jpg" />

and should be fine with it. My problem is, I have a couple of web-controls
within a 'controls' subdirectory which I use throughout the site. The aspx
pages are located in different nested subdirectories. One of the controls
which is hosted on almost every page links to an image. Due to the different
'levels' at which the aspx page might be, the image is not displayed
sometimes.

I can't use absolute path values since server names might vary. There are
dusty and vague memories of specifying relative path like this

<img src="/sub2/img1.jpg" />
or
<img src="~/sub2/img1.jpg" />

but neither yields the desired results. How do you do this?

Thanks in advance!

/matthias
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top