2

so: I've read 8+ stackover flows on relative to absolute. A few sites and went to MS page on this...

however when I've tried and had not success. Then I researched more and wonder solutions I read about are not part of .asp and just asp.net? (yup, I'm a novice / newbie / ignorant)

The situation and my aspiration:

I have a site that was initial just a few products and pages of text / images(~10), the number of products has doubled and I want to migrate to a tree structure for SEO / personal sanity / organization.

The original builder of site used This was great on single layer set up, as it is now.

i.e. example.com/page1.asp

Now I'm putting reviews (lengthy multiple page product reports), adding multiple products, etc on different depths in a tree. So while I can accurately connect to a relative include on

example.com/products/super-widgets/widget/reviews/index.asp

 <!-- #include file="../../../../../../inc-footer.asp" -->  

the sources inside the include break on as they are relative.

As I have attempted to research, stated above, I have tried to find a "best practice" for converting the relative to absolute for the information in the /inc-footer.asp file. I have consider putting an absolute path for agent to get global images

<img src="http://example.com/images/ex1.png">.

However I believe some say this is a poor choice for coding, I think it is because of speed of experience of clients / web visitors, but I don't know this.

So I have attempted a few trials and errors based on my earlier research with no avail....

inside the include file.asp I have (and failed to succeed with):

from this sites examples (link) I tried:

<img runat="server" src="~/images/tab-leftside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />

and from MS (link) I tried:

<asp:image runat="server" ImageUrl="~/images/tab-rightside.png" alt="design object" width="21" height="20" class="tab-img" /> <a href="javascript:switchid('tab1');" onfocus="this.blur()" >Page 1</a> <img src="" />

while writing this I referenced some of recommendations and tried & failed with ( link )

<img  src="<%= VirtualPathUtility.ToAbsolute("~/images/tab-rightside.png") %>" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />

Then I thought I need to modify above example and tried

<img  src="<%= VirtualPathUtility.ToAbsolute("~/images/") %>tab-rightside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />

Again with cross reference in writing this (link), I considered a but the include file has no

Only success I have had success with absolute path to http://

<img  src="http://example.com/images/tab-leftside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />

Presently, the site is hosted on Windows Server 2003 Microsoft-IIS/6.0

All of the page files are .asp

I use Google chrome to define success in testing above examples. As I experience if it doesn't' work in chrome it's not worth testing in other browsers.

Thanks. Casey Burnett

Jon P
  • 19,442
  • 8
  • 49
  • 72
Casey Burnett
  • 23
  • 1
  • 4
  • See this answer to a recent asp-classic question: http://stackoverflow.com/questions/7963635/resolveurl-url-content-equivalent-in-classic-asp/7972602#7972602 – AnthonyWJones Nov 03 '11 at 09:06

2 Answers2

3
<img src='<%= Page.ResolveUrl("~/images/tab-rightside.png") %>' 
    class="tab-img" width="22" height="20" />
    <a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a>
    <img src="" />
rick schott
  • 21,012
  • 5
  • 52
  • 81
  • Thank you.unfortunately I received an error in testing with this too. – Casey Burnett Nov 02 '11 at 18:20
  • Thank you. Unfortunately I received an error in testing with this too. Just to clarify there are just four lines of code pointing to separate page each looks like this (plus id= and class= which I edited out of fit limits of this comment box] in the Include file.asp `Page 1` – Casey Burnett Nov 02 '11 at 18:29
2

Runat = Server won't work for classic ASP. Classic ASP and ASP.net are not interchangeable. They work completely differently.

Regardless of framework I've found Root relative paths work well when your development site is not using local host.

** Root Relative example**

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

Here is an article on the different path types: http://brugbart.com/Articles/paths

If you can I would use Root Relative paths, if not use absolute URLs. The only penalty for Absolute URLs the download overhead of a few extra characters in the URL.

Jon P
  • 19,442
  • 8
  • 49
  • 72