ResolveUrl vs ~

Discussion in 'ASP .Net' started by bryanp10@hotmail.com, Jun 22, 2007.

  1. Guest

    Are there any advantages/disadvantages between these two approaches:

    <img src="~/images/nav_01.gif" runat="server">

    vs.

    <img src="<%=ResolveUrl("~/images/nav_01.gif")%>">

    Are they more or less the same thing? I've noticed that they render
    differently, but I can't think of a situation where they should behave
    differently as far as end results are concerned.
     
    , Jun 22, 2007
    #1
    1. Advertising

  2. On Jun 23, 12:37 am, "" <>
    wrote:
    > Are there any advantages/disadvantages between these two approaches:
    >
    > <img src="~/images/nav_01.gif" runat="server">
    >
    > vs.
    >
    > <img src="<%=ResolveUrl("~/images/nav_01.gif")%>">
    >
    > Are they more or less the same thing? I've noticed that they render
    > differently, but I can't think of a situation where they should behave
    > differently as far as end results are concerned.


    Take a look at the following article

    Table 2 Differences Between Declarative versus Programmatic Path
    Resolution
    http://www.awprofessional.com/articles/article.asp?p=101145&seqNum=2&rl=1

    <asp:Image runat="server" ImageUrl="~/images/hi.gif" />

    returns:

    .../images/hi.gif

    ResolveUrl("~/images/hi.gif")

    returns:

    informit/images/hi.gif

    I think it's just a matter of app's design...
     
    Alexey Smirnov, Jun 23, 2007
    #2
    1. Advertising

  3. MasterGaurav \(www.edujini-labs.com\), Jun 24, 2007
    #3
  4. > <asp:Image runat="server" ImageUrl="~/images/hi.gif" />
    >
    > returns:
    >
    > ../images/hi.gif
    >
    > ResolveUrl("~/images/hi.gif")
    >
    > returns:
    >
    > informit/images/hi.gif


    That's correct! But IMHO, the main question still remains -- what happens
    behind the scene.
    The document is also silent about it.
    I have just posted a small FAQ detailing what happens at
    http://faqs.edujini-labs.com/1_5_en.html

    See my earlier posting to the thread... it's about ResolveClientUrl vs.
    ResolveUrl.

    The ResolveUrl is relative to TemplateSourceDirectory. For the ASPX pages,
    the TemplateSourceDirectory is the folder where Application-Context relative
    folder where the ASPX page resides.

    The ResolveClientUrl returns a URL relative to the current-page rather than
    virtual-path.


    HTH.


    --
    Happy Hacking,
    Gaurav Vaish | www.mastergaurav.com
    www.edujini-labs.com
    http://eduzine.edujini-labs.com
    -----------------------------------------
     
    MasterGaurav \(www.edujini-labs.com\), Jun 24, 2007
    #4
    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:
    833
    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,751
    Sirko
    Oct 31, 2007
  3. Lloyd Dupont

    alternative to ResolveUrl()

    Lloyd Dupont, Jan 29, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    607
    Lloyd Dupont
    Jan 29, 2006
  4. SandyIsCool
    Replies:
    4
    Views:
    572
    Edwin Knoppert
    Dec 15, 2006
  5. SandyIsCool

    small doubt regarding ResolveURL

    SandyIsCool, Dec 15, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    521
    SandyIsCool
    Dec 15, 2006
Loading...

Share This Page