ResolveUrl vs ~

B

bryanp10

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

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.

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

MasterGaurav \(www.edujini-labs.com\)

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

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top