How to use "~" for approot

A

A Traveler

Hello, i have a control i wrote which inherits from the ImageButton control.

On the ImageButton.ImageUrl property, you can use "~" to represent the root
of your application (vs. the domain root), so if my app resides @
www.myserver.com/myapp/ and i put in an image i can set its imageurl to
"~/images/some.gif". Then when the framework renders it, it renders the SRC
for that image as www.myserver.com/myapp/images/some.gif.

My derived control adds a HotImageUrl (for onmouseover). It works fine, uses
the imagebrowser property designer and everything. Only problem is it doesnt
know how to handle the "~" as a reference to the app's root. In my code for
the control, what is the code i would use to retrieve the applications root
url (ie. www.myserver.com/myapp) and handle the "~" properly?

Thanks in advance,

- Arthur Dent.
 
J

John Saunders

A Traveler said:
Hello, i have a control i wrote which inherits from the ImageButton control.

On the ImageButton.ImageUrl property, you can use "~" to represent the root
of your application (vs. the domain root), so if my app resides @
www.myserver.com/myapp/ and i put in an image i can set its imageurl to
"~/images/some.gif". Then when the framework renders it, it renders the SRC
for that image as www.myserver.com/myapp/images/some.gif.

My derived control adds a HotImageUrl (for onmouseover). It works fine, uses
the imagebrowser property designer and everything. Only problem is it doesnt
know how to handle the "~" as a reference to the app's root. In my code for
the control, what is the code i would use to retrieve the applications root
url (ie. www.myserver.com/myapp) and handle the "~" properly?

I think you want to use Control.ResolveUrl(HotImageUrl) to create the Url
you want to render to the client.
 

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,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top