small doubt regarding ResolveURL

S

SandyIsCool

Hi

I used the below code for an image button


image1.imageurl="~/images/image1.jpg";
image1.imageurl=Page.ResolveUrl("~/images/image1.jpg");


Both statements work fine..
I want to see a case where resolveURL method makes a difference.
Thanks,
Sandeep
 
J

Juan T. Llibre

Sandy,

ResolveUrl is very useful when you need to move applications from one server
to another, where the directory structure might be completely different.

If you have a server with a virtual application /Foo :

image1.imageurl=Page.ResolveUrl("~/images/image1.jpg");
will return "/Foo/images/image1.jpg"

If you have a server with a virtual application /Bar :

image1.imageurl=Page.ResolveUrl("~/images/image1.jpg");
will return "/Bar/images/image1.jpg"

Notice that the *same* code resolves different base URLs,
even though the *relative* URLs are identical.
 
S

SandyIsCool

Hi Juan,
thanks for the quick reponse.

But ("~/images/image1.jpg) still can be assigned to imageurl without
using resolving url function. As I said
image1.imageurl="~/images/image1.jpg";
image1.imageurl=Page.ResolveUrl("~/images/image1.jpg");

both work fine. ~ also works without resolveURL function.

Thanks,
Sandeep
 

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,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top