Best way to use a header include file?

J

John Dalberg

I created a header file to be included in every webpage. The header file
has images that have a path to an "images" folder off the root folder.
However if I use this header file for web pages that reside in subfolders,
I have to change the path of all the image links to '../images/' instead of
'images/'.

What's the best way to have a single header file which *any* web page,
regardless of its location, can use without modifying it to suit certain
webpages depedning on their location?
 
J

Juan T. Llibre

"~/images/whatever.ext" will work for any application folder.

"~" stand for the application root in ASP.NET,
so if you have a directory structure like this :

root
/images
/anotherdir
/anotherdir/someotherdir
/anotherdir/someotherdir/yetanotherdir

"~/images/whatever.ext" will reference root/images
from all those directories.



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
J

John Dalberg

"~/images/whatever.ext" will work for any application folder.

"~" stand for the application root in ASP.NET,
so if you have a directory structure like this :

root
/images
/anotherdir
/anotherdir/someotherdir
/anotherdir/someotherdir/yetanotherdir

"~/images/whatever.ext" will reference root/images
from all those directories.


Thanks. Where is this mentioned in the help file or MSDN? I don't even know
what keyword to use for this.

John
 
A

Alan Silver

If the images are all in /images, then why bother with the ~ sign?
That's only for server controls anyway, so you have to remember to use /
in client stuff.

It would be easier to use /images for everything, as that will always
resolve to the images folder off the domain's root. No?
 

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