473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ResolveUrl vs ~

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 '07 #1
3 11320
On Jun 23, 12:37 am, "bryan...@hotmail.com" <bryan...@hotmail.com>
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...

Jun 23 '07 #2
<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
-----------------------------------------
Jun 24 '07 #3
<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
-----------------------------------------
Jun 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lloyd Sheen | last post by:
I have a weird (at least to those who think the IDE should work) problem. I have in code the following: psFiles = Page.ResolveUrl("/Pictures") This resolves to /Pictures in the code In...
4
by: Lloyd Dupont | last post by:
When I want some app resources I usually write something like: MapPath(ResolveUrl("~/App_Data/MyResource")) How could I do the same thing in a static helper method? I mean MapPath & ResolveUrl...
0
by: Lloyd Dupont | last post by:
I'm writing an web element (in fact a ToolbarButtopn for FreeTextBox), which is not a subclass of SWU.Control. I need to know the client path for something like: "~/utils/Gallery.aspx" In...
4
by: SandyIsCool | last post by:
Hi, Can any one let me know what is difference between Server.mappath and Page.resolveURL and what are the situations we use them. Thanks, Sandy
2
by: SandyIsCool | last post by:
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..
20
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is...
6
by: tshad | last post by:
I am finally getting the path to the Current Page using Page.ResolveURL. I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what I was looking for. But what is the syntax to...
1
by: NightOwl888 | last post by:
I have an older web project that I am trying to update with new .NET 2.0 features. I put new master pages in a subdirectory below the project directory. This particular project runs under IIS...
2
by: Max2006 | last post by:
Hi, Is it possible to have the functionality of ResolveURL within *.ashx files? Thank you,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.