开发者

What is the difference between these two Html statements?

开发者 https://www.devze.com 2023-02-17 09:33 出处:网络
What is the difference between these two Html statements. <asp:Image runat=\"server\" ID=\"imgHelp\"ImageUrl=\"~/images/help.gif\" />

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:

0

精彩评论

暂无评论...
验证码 换一张
取 消