我看到别人这样使用:
<img src="~/images/520.gif" border="0">
[~]这个符号是返回最顶级目录吗?
为什么我这样使用不行呢?[..]这个符号是返回上一级目录

解决方案 »

  1.   

    <img src="~/images/520.gif" border="0" runat="server">
    这样就行了“~ /” → 只有服务器认识,指的是“项目的根目录”,下列示例的项目根目录是 http://localhost/WebTest以“/”开头的 URL 指的是回到站点根目录
    以“../”开头的 URL 指的是回到上层目录
    以“./”开头的 URL 指的是当前目录http://localhost/WebTest/Pub/WebForm1.aspx  中的 “src="../a.gif"”是指向 http://localhost/WebTest/a.gif ……服务器的文件为“F:\work\progame\WebTest\a.gif”http://localhost/WebTest/Pub/WebForm1.aspx  中的 “src="./a.gif"”是指向 http://localhost/WebTest/Pub/a.gif  ……服务器的文件为“F:\work\progame\WebTest\Pub\a.gif”http://localhost/WebTest/Pub/WebForm1.aspx  中的 “src="/a.gif"”是指向 http://localhost/a.gif  ……服务器的文件为“C:\Inetpub\wwwroot\a.gif”
      

  2.   

    <img src="~/images/520.gif" border="0" runat="server" ID="Img_520">
    少了 ID ,呵呵,不好意思