User control + relative path

A

Alex

Hi. I need some help on this.
I have a user control (a header) in my root directory, and all my pages use
that control. Then a created a folder (in my root directory) and put a new
page inside it, and that page use the same control, but this time the
control can't find it's images and resources because it is trying to find it
in the same folder instead of the root directory. Now, I know that I can
change the control image's relative paths for absolute paths, but then when
I upload my application to the real server I have to change all the paths
again. Of course I could make a copy of the control in my new folder but
then I have to copy all the images and everything too.
Is there some simple way of dealing with that?
Thanks,
Alejandro Penate-Diaz.
 
A

A Traveler

Hello,

I had this same problem recently, and with a little ng help i was able to
get it fixed.
What works very well is the following...

In your usercontrol, call ResolveUrl as follows:

Me.ResolveUrl("~/images/myimage.gif")

You need the "~/", and then the rest is simply the path to your image
relative to the root of your application (note, this is NOT the root of the
site, but the root of the app, which may be different if the app is in a
subdirectory of the site).

Hope this helps.
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top