Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ResolveUrl vs ~

Reply
Thread Tools

ResolveUrl vs ~

 
 
bryanp10@hotmail.com
Guest
Posts: n/a
 
      06-22-2007
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.

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-23-2007
On Jun 23, 12:37 am, "(E-Mail Removed)" <(E-Mail Removed)>
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/articl...&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...

 
Reply With Quote
 
 
 
 
MasterGaurav \(www.edujini-labs.com\)
Guest
Posts: n/a
 
      06-24-2007
> <img src="~/images/nav_01.gif" runat="server">


In this case, the method ResolveClientUrl of the class Control is called
rather than ResolveUrl.

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------


 
Reply With Quote
 
MasterGaurav \(www.edujini-labs.com\)
Guest
Posts: n/a
 
      06-24-2007
> <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
-----------------------------------------


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ResolveUrl in a static helper method Lloyd Dupont ASP .Net 5 10-31-2007 10:37 AM
Difference between Server.mappath and Page.resolveURL SandyIsCool ASP .Net 4 12-15-2006 01:59 PM
small doubt regarding ResolveURL SandyIsCool ASP .Net 2 12-15-2006 11:58 AM
alternative to ResolveUrl() Lloyd Dupont ASP .Net 0 01-29-2006 08:24 AM
More woes ResolveUrl Lloyd Sheen ASP .Net 1 01-26-2004 05:39 AM



Advertisments