Problems with using the ~ character to designate rootpath

fld00d

Member
Joined
May 9, 2009
Messages
5
Programming Experience
Beginner
Hello,

Not sure this post is in the correct location.

I have created an ASCX file as user control.
VB.NET:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="defaultTestimonials.ascx.vb" Inherits="usercontrols_defaultTestimonials" %>
<asp:Image ID="Image5" runat="server" ImageAlign="Top" ImageUrl="~/images/testimonials.gif" />
<table>
    <tr>
        <td>
            <br />
            <table>
                <asp:Repeater ID="Repeater1" DataSourceID="XmlDataSource1" runat="server"> 
                <itemtemplate>               
                <tr>
                    <td align="center">
                        <span class="xmlrptr-desc-title">
                        <strong class="xmlrptr-desc-title"><%#XPath("@name")%>
                        </strong>
                        </span>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <a href="/testimonials.aspx" style="text-decoration: none; outline-style:none;">
                        <img src="~/images/<%#XPath("image") %>" alt="Carburetor Testimonial Image">
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="Center">
                        <span class="xmlrptr-desc-text"><%#XPath("shortdesc")%>
                        </span>
                        <br />
                        <br />
                    </td>
                </tr>   
                </itemtemplate>                
                </asp:Repeater>
            </table>
        </td>
    </tr>    
</table>

When I use the <ASP:Button> tag, the ~ character works just fine. However, when I use the <Img> tag it doesn't. I can't use the <ASP:Button> tag in this case because it is part of an XML repeater, and I cannot assign the ID portion of the <ASP:Button> tag.

Any suggestions?
 
ASP.NET Web Site Paths, this explains the ~ server path instruction and also relative paths for client elements.
 
Ok, so that post helped out tremendously... I still have one more question.

My aspx content files have some VB.Net code that suck in an HTM file in the content folder. If I use the tag:
VB.NET:
<img src="images/test.gif">
The masterpage and content file loads the file correctly, since the path is determined by the masterpage that is loading the content HTM file. So, no problem there.

Now, I have also written an application that manages the content using FreeTextBox. The aspx and code behind files that use FreeTextBox are in the '/admin' folder. When the FreeTextBox DLL loads the HTM content, it can't find the image. But, like I said, it works when the website is viewed just not during the editing.

Any ideas of how I could get around this sticky issue?


The dir structure of the application is as follows:
(In true old-school DOS dirtree format)

/
|
+-admin
|
+-content
|
+-images
 
Back
Top