By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,866 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,866 IT Pros & Developers. It's quick & easy.

Root Relative Path

P: n/a
I have a snippet of HTML that I inject into a number of pages throughout my
Web site at runtime. My problem is that I'm not getting the image to appear
in all documents into which this snippet is injected.

If I specify a document-relative path (e.g.,
src="../someFolder/AnotherFolder/TheGraphic.gif"), then it works fine, but
only for documents that exist at the [someFolder] level in the directory
structure.

I thought I could use a root-relative path, as follows, in order for the
image to appear on all documents throughout my site:
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

But that doesn't seem to work.

How can I specify the src attribute value in order to have the image show up
correctly on all documents - regardless of the documents location in the
site's folder hierarchy?

Please note that I'm building one simple HTML string that is the same for
all pages into which it is injected - so there is no opportunity or desire
to inject a different string per document.

Thanks!
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Don't forget about the tilde (~) in ASP.NET. It resolves to the root of your
site. Therefore you can use something like

"~/images/myimage.gif"

from anywhere.

Ken

"Win, Pats" <IJ********@SpamThis.com> wrote in message
news:ug****************@TK2MSFTNGP09.phx.gbl...
I have a snippet of HTML that I inject into a number of pages throughout my
Web site at runtime. My problem is that I'm not getting the image to appear
in all documents into which this snippet is injected.

If I specify a document-relative path (e.g.,
src="../someFolder/AnotherFolder/TheGraphic.gif"), then it works fine, but
only for documents that exist at the [someFolder] level in the directory
structure.

I thought I could use a root-relative path, as follows, in order for the
image to appear on all documents throughout my site:
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

But that doesn't seem to work.

How can I specify the src attribute value in order to have the image show
up correctly on all documents - regardless of the documents location in
the site's folder hierarchy?

Please note that I'm building one simple HTML string that is the same for
all pages into which it is injected - so there is no opportunity or desire
to inject a different string per document.

Thanks!


Nov 19 '05 #2

P: n/a
Unfortunately the tilde reference to the root doesn't help in my situation
because ASP.NET isn't resolving the path. What I'm doing is simply injecting
a string of HTML into the pages via a Literal control - so it's the browser
that needs to know where the root is...

I thought that starting a path with a '/' causes a path to be
"root-relative" according to HTML fundamentals (as used in the following
<img> tag):
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

Am I incorrect about that?


"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Don't forget about the tilde (~) in ASP.NET. It resolves to the root of
your site. Therefore you can use something like

"~/images/myimage.gif"

from anywhere.

Ken

"Win, Pats" <IJ********@SpamThis.com> wrote in message
news:ug****************@TK2MSFTNGP09.phx.gbl...
I have a snippet of HTML that I inject into a number of pages throughout
my Web site at runtime. My problem is that I'm not getting the image to
appear in all documents into which this snippet is injected.

If I specify a document-relative path (e.g.,
src="../someFolder/AnotherFolder/TheGraphic.gif"), then it works fine,
but only for documents that exist at the [someFolder] level in the
directory structure.

I thought I could use a root-relative path, as follows, in order for the
image to appear on all documents throughout my site:
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

But that doesn't seem to work.

How can I specify the src attribute value in order to have the image show
up correctly on all documents - regardless of the documents location in
the site's folder hierarchy?

Please note that I'm building one simple HTML string that is the same for
all pages into which it is injected - so there is no opportunity or
desire to inject a different string per document.

Thanks!

Nov 19 '05 #3

P: n/a
re:
I thought that starting a path with a '/' causes a path to be
"root-relative" according to HTML fundamentals
Sure, depending on where the "root" is configured.

Your "root directory" is always going to be wwwroot, if you
haven't configured a downlevel directory as an application.

In that case, "/someFolder/AnotherFolder/TheGraphic.gif"
refers to wwwroot/someFolder/AnotherFolder/TheGraphic.gif.

If you *have* configured an application at /someotherFolder,
then *that* relative root is /someotherFolder, and a link like
"/someFolder/AnotherFolder/TheGraphic.gif" at *that* location
will refer to
wwwroot/someotherFolder/someFolder/AnotherFolder/TheGraphic.gif

Bottom line is, you can't have the same images directory
for different applications, because the root directory will
vary for each application.


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

"Win, Pats" <IJ********@SpamThis.com> wrote in message
news:es*************@tk2msftngp13.phx.gbl... Unfortunately the tilde reference to the root doesn't help in my situation
because ASP.NET isn't resolving the path. What I'm doing is simply
injecting a string of HTML into the pages via a Literal control - so it's
the browser that needs to know where the root is...

I thought that starting a path with a '/' causes a path to be
"root-relative" according to HTML fundamentals (as used in the following
<img> tag):
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

Am I incorrect about that?


"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Don't forget about the tilde (~) in ASP.NET. It resolves to the root of
your site. Therefore you can use something like

"~/images/myimage.gif"

from anywhere.

Ken

"Win, Pats" <IJ********@SpamThis.com> wrote in message
news:ug****************@TK2MSFTNGP09.phx.gbl...
I have a snippet of HTML that I inject into a number of pages throughout
my Web site at runtime. My problem is that I'm not getting the image to
appear in all documents into which this snippet is injected.

If I specify a document-relative path (e.g.,
src="../someFolder/AnotherFolder/TheGraphic.gif"), then it works fine,
but only for documents that exist at the [someFolder] level in the
directory structure.

I thought I could use a root-relative path, as follows, in order for the
image to appear on all documents throughout my site:
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

But that doesn't seem to work.

How can I specify the src attribute value in order to have the image
show up correctly on all documents - regardless of the documents
location in the site's folder hierarchy?

Please note that I'm building one simple HTML string that is the same
for all pages into which it is injected - so there is no opportunity or
desire to inject a different string per document.

Thanks!


Nov 19 '05 #4

P: n/a
Thank you so much for the great explanation. The clarafication of "what
specifically is the site root" is was what I was missing.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
re:
I thought that starting a path with a '/' causes a path to be
"root-relative" according to HTML fundamentals


Sure, depending on where the "root" is configured.

Your "root directory" is always going to be wwwroot, if you
haven't configured a downlevel directory as an application.

In that case, "/someFolder/AnotherFolder/TheGraphic.gif"
refers to wwwroot/someFolder/AnotherFolder/TheGraphic.gif.

If you *have* configured an application at /someotherFolder,
then *that* relative root is /someotherFolder, and a link like
"/someFolder/AnotherFolder/TheGraphic.gif" at *that* location
will refer to
wwwroot/someotherFolder/someFolder/AnotherFolder/TheGraphic.gif

Bottom line is, you can't have the same images directory
for different applications, because the root directory will
vary for each application.


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

"Win, Pats" <IJ********@SpamThis.com> wrote in message
news:es*************@tk2msftngp13.phx.gbl...
Unfortunately the tilde reference to the root doesn't help in my
situation because ASP.NET isn't resolving the path. What I'm doing is
simply injecting a string of HTML into the pages via a Literal control -
so it's the browser that needs to know where the root is...

I thought that starting a path with a '/' causes a path to be
"root-relative" according to HTML fundamentals (as used in the following
<img> tag):
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

Am I incorrect about that?


"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Don't forget about the tilde (~) in ASP.NET. It resolves to the root of
your site. Therefore you can use something like

"~/images/myimage.gif"

from anywhere.

Ken

"Win, Pats" <IJ********@SpamThis.com> wrote in message
news:ug****************@TK2MSFTNGP09.phx.gbl...
I have a snippet of HTML that I inject into a number of pages throughout
my Web site at runtime. My problem is that I'm not getting the image to
appear in all documents into which this snippet is injected.

If I specify a document-relative path (e.g.,
src="../someFolder/AnotherFolder/TheGraphic.gif"), then it works fine,
but only for documents that exist at the [someFolder] level in the
directory structure.

I thought I could use a root-relative path, as follows, in order for
the image to appear on all documents throughout my site:
<img src="/someFolder/AnotherFolder/TheGraphic.gif">

But that doesn't seem to work.

How can I specify the src attribute value in order to have the image
show up correctly on all documents - regardless of the documents
location in the site's folder hierarchy?

Please note that I'm building one simple HTML string that is the same
for all pages into which it is injected - so there is no opportunity or
desire to inject a different string per document.

Thanks!



Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.