small doubt regarding ResolveURL

Discussion in 'ASP .Net' started by SandyIsCool, Dec 15, 2006.

  1. SandyIsCool

    SandyIsCool Guest

    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
     
    SandyIsCool, Dec 15, 2006
    #1
    1. Advertising

  2. 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.





    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "SandyIsCool" <> wrote in message
    news:...
    > 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
    >
     
    Juan T. Llibre, Dec 15, 2006
    #2
    1. Advertising

  3. SandyIsCool

    SandyIsCool Guest

    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

    Juan T. Llibre wrote:
    > 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.
    >
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "SandyIsCool" <> wrote in message
    > news:...
    > > 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
    > >
     
    SandyIsCool, Dec 15, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lloyd Sheen

    More woes ResolveUrl

    Lloyd Sheen, Jan 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    852
    Natty Gur
    Jan 26, 2004
  2. Lloyd Dupont

    ResolveUrl in a static helper method

    Lloyd Dupont, Jan 11, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    15,823
    Sirko
    Oct 31, 2007
  3. Lloyd Dupont

    alternative to ResolveUrl()

    Lloyd Dupont, Jan 29, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    632
    Lloyd Dupont
    Jan 29, 2006
  4. SandyIsCool
    Replies:
    4
    Views:
    590
    Edwin Knoppert
    Dec 15, 2006
  5. ResolveUrl vs ~

    , Jun 22, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    802
    MasterGaurav \(www.edujini-labs.com\)
    Jun 24, 2007
Loading...

Share This Page