Tilde Expansion

M

MB2

I have code in a User Control for an image button like this:
<asp:ImageButton id="__0" runat="server" text="Delete"
ImageUrl="~/Images/ImageLibrary/icon_delete.gif" />

This used to work and it would display the image properly.

However, since installing the latest service pack for the .NET
Framework 1.1, the tilde seems to be expanding improperly. The code
that is expanded to shows this:
<input type="image" name="Template1:_fixed0:_fixed0:_ctl0:Repeater_0:_ctl5:__0"
id="Template1__fixed0__fixed0__ctl0_Repeater_0__ctl5___0"
text="Delete" src="../../Images/ImageLibrary/icon_delete.gif" alt=""
border="0" />

Unfortunately src="../../Images" is not the correct path to that
directory. Does anyone know if Microsoft implemented the tilde
expansion differently than before. Does anyone know if there is a way
around this problem?

Any help is greatly appreciated.

Thanks,
Morry
 
R

Rick Strahl [MVP]

The ~ should link back to the application root which is where the virtual is
defined. So maybe something has changed in the way that you are referencing
the approot?

At the control level this behavior may look different than at the page
level. Take a look at Page.ResolveUrl() and Control.ResolveUrl() which are
used to resolve the ~...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top