What is the difference between these two Html statements.
<asp:Image runat="server" ID="imgHelp" ImageUrl="~/images/help.gif" />
&
<asp:Image开发者_JS百科 runat="server" ID="imgHelp" ImageUrl="/images/help.gif" />
One image path is absolute (~/images/help.gif) and one is relative (/images/help.gif)
Their path to image differs.
This one is a nice overview of how to handle asp.net paths:
~/ Root Relative Paths and ResolveUrl() and ResolveClientUrl()
ASP.NET supports root-relative virtual path syntax in most of its URL properties in Web Forms.
So you can easily specify a root relative path in a control rather than a location relative path:
精彩评论