473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Root Relative Path

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
4 7824
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: | last post by:
Is it possible to include my remote web server path eg: m:/html/root/site1 | m:/html/root/site2 etc ....in virtual includes.... Thus eliminating the need to create duplicate INC files in each...
5
by: Jonathan | last post by:
I am creating a CD-ROM based website template. Things work fine under Windows but when I try to run the site under Linux the path is messed up. Therefore my JavaScript functions misinterpret the...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
3
by: Dave | last post by:
Hi, since I'm developing on XP and can only have on website, how can you refer to your root application (not web) in your paths? I read for server controls that "the ~/ prefix will be converted...
2
by: Jordan Richard | last post by:
Put another way, is there any way I can tell ASP.NET to convert a path (imbedded in a string variable, "~/images/some_image.gif") to a root-relative path, that the client will understand, for the...
2
by: tsteinke | last post by:
Okay here is the situation I am developing a ASP.Net application locally and then I copy the project up to my web server. I start out by creating an ASP.NET Application ...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
2
by: ECRIA | last post by:
Hi All, We are trying to figure out why PHP's file handling functions refuses to access the web root using the "/" character on our Windows machines. For example, a file /test.php is located in...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.