Hongbo:
Yes, there is a performance setback, but it's very small and probably worth
paying it (we are talking microseconds most likely).
If this isn't acceptable, you can have a global class with a property such
as:
public sealed class Globals{
static public string ApplicationPath {
get {
string applicationPath = HttpContext.Current.Request.ApplicationPath;
if (applicationPath == "/") {
return string.Empty;
}
return applicationPath;
}
}
}
}
and then use src="<%=Globals.ApplicationPath%>images/logo1.jpg" but I my
personal opinion is that ~ is much nicer and cleaner with a very low cost.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"hb" <ho****@goodoffices.com> wrote in message
news:ON****************@TK2MSFTNGP12.phx.gbl...
Hi,
Recently I read some articles about the root path reference in ASP.Net
application.
One recommended way is to use "~" at the beginning of the path with server
control.
for example:
<img runat="server" src="~/images/logo1.jpg">
Those articles also say that such method works with virtual directory as
well.
My question is: Is there any performance setback to use server side HTML
tag (like <img runat="server">)or even ASP.Net server control (like
<asp:image>)
instead of regular HTML tag (like <img>) just for root reference purpose?
Thank you
Hongbo