Newbie #include question

K

Kent

I am sure this is pretty basic, but we all have to start somewhere
right?

I have a asp file that is a couple of sub dirs deep. In it is a
include that pulls in a common file from the root.

My problem is the file in the root has a background picture that also
resides in the root, and it doesn't get loaded with the file in the
sub. If I move the asp file out of the sub and up to the root then it
all loads fine.

I presume I need a absolute path to the picture, but how do I set it
up so I don't have to remember to edit it when I post to the web.

Thanks in advance for any help
 
R

Ray at

Use a path that is relative from the root.

<img src="/images/file.gif">

The leading / will tell the browser to start at the root of the site to look
for that image. So, whether you're at
yoursite.com/dir/dir/dir/dir/dir/dir/dir/dir/dir/dir/page.asp or
yoursite.com/page.asp, that /images/file.gif will be a valid path
regardless.

Ray at work
 
T

TomB

Just for clarity. Virtual in an include means Absolute.
<!--#Include Virtual="rootfolder\dir\file.asp"--> would go to
yoursite.com/dir/file.asp



Hi,

Alternatively you can also set the image or the include file using a virtual
path like:-

for directory structure

yoursite.com/dir/dir/dir/dir/page.asp and ur image is in
yoursite.com/images/1.gif

then

<img src="../../../../../images/1.gif"

Actually, i think its a better idea because, if some later time you need to
change the files to another server and you dont get the same structure, like
your files are not directly in the wwwroot folder, instead there is a folder
by your name and the files are in there, then your image folder would be two
steps deep, rather than one in the current situation. So always use virtual
paths for absolute safety.

Regards,
Bhaskardeep Khaund
 

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
474,141
Messages
2,570,816
Members
47,362
Latest member
ayamcy

Latest Threads

Top