Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes runat="server" img scr=~/img/ex1.png" work in ASP or only ASP.net | Relative to Absolute path in include
    text
    copied!<p>so: I've read 8+ stackover flows on relative to absolute. A few sites and went to MS page on this... </p> <p>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)</p> <p>The situation and my aspiration:</p> <p>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.</p> <p>The original builder of site used This was great on single layer set up, as it is now. </p> <p>i.e. <code>example.com/page1.asp</code></p> <p>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 </p> <pre><code>example.com/products/super-widgets/widget/reviews/index.asp &lt;!-- #include file="../../../../../../inc-footer.asp" --&gt; </code></pre> <p>the sources inside the include break on as they are relative. </p> <p>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 </p> <p><code>&lt;img src="http://example.com/images/ex1.png"&gt;</code>. </p> <p>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.</p> <p>So I have attempted a few trials and errors based on my earlier research with no avail....</p> <p>inside the include file.asp I have (and failed to succeed with):</p> <p>from this sites examples (<a href="http://weblogs.asp.net/fmarguerie/archive/2004/05/05/avoiding-problems-with-relative-and-absolute-urls-in-asp-net.aspx" rel="nofollow">link</a>) I tried: </p> <pre><code>&lt;img runat="server" src="~/images/tab-leftside.png" class="tab-img" width="22" height="20" /&gt;&lt;a href="javascript:switchid('tab2');" onfocus="this.blur()" &gt;Page 2&lt;/a&gt;&lt;img src="" /&gt; </code></pre> <p>and from MS (<a href="http://msdn.microsoft.com/en-us/library/ms178116.aspx" rel="nofollow">link</a>) I tried:</p> <pre><code>&lt;asp:image runat="server" ImageUrl="~/images/tab-rightside.png" alt="design object" width="21" height="20" class="tab-img" /&gt; &lt;a href="javascript:switchid('tab1');" onfocus="this.blur()" &gt;Page 1&lt;/a&gt; &lt;img src="" /&gt; </code></pre> <p>while writing this I referenced some of recommendations and tried &amp; failed with ( link )</p> <pre><code>&lt;img src="&lt;%= VirtualPathUtility.ToAbsolute("~/images/tab-rightside.png") %&gt;" class="tab-img" width="22" height="20" /&gt;&lt;a href="javascript:switchid('tab2');" onfocus="this.blur()" &gt;Page 2&lt;/a&gt;&lt;img src="" /&gt; </code></pre> <p>Then I thought I need to modify above example and tried</p> <pre><code>&lt;img src="&lt;%= VirtualPathUtility.ToAbsolute("~/images/") %&gt;tab-rightside.png" class="tab-img" width="22" height="20" /&gt;&lt;a href="javascript:switchid('tab2');" onfocus="this.blur()" &gt;Page 2&lt;/a&gt;&lt;img src="" /&gt; </code></pre> <p>Again with cross reference in writing this (link), I considered a but the include file has no </p> <p>Only success I have had success with absolute path to http://</p> <pre><code>&lt;img src="http://example.com/images/tab-leftside.png" class="tab-img" width="22" height="20" /&gt;&lt;a href="javascript:switchid('tab2');" onfocus="this.blur()" &gt;Page 2&lt;/a&gt;&lt;img src="" /&gt; </code></pre> <p>Presently, the site is hosted on Windows Server 2003 Microsoft-IIS/6.0</p> <p>All of the page files are .asp</p> <p>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.</p> <p>Thanks. Casey Burnett</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload