Absolute or Relative path?
by matthias s. » Sat, 09 Jul 2005 05:44:46 GMT
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