如何从文件夹内的ASP.NET页访问图像 [英] How to access image from ASP.NET page inside folder

查看:69
本文介绍了如何从文件夹内的ASP.NET页访问图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的asp.net项目中,我有一个包含我的图像的图像文件夹,
以及另一个具有Specific.aspx页和母版页的文件夹.

我无法从Specific.aspx页面访问图像.

那是我的尝试:

Hi,

In my asp.net project, i have image folder that has my images,
and another folder that has Specific.aspx page and Master Page for it.

I cannot reach images from Specific.aspx page.

That is my try:

<img alt="Start" class="butClass" src="~/img/toolbar.Start.gif" />



但它不起作用.



but it not work.

推荐答案

请勿使用〜/".必须为"./img/toolbar.Start.gif"或仅为"img/toolbar.Start.gif".当然,请确保子目录"img"与包含此代码的页面文件位于同一目录中.换句话说,使用相对路径.相对于使用它们的页面位置.

—SA
Don''t use "~/". Must be "./img/toolbar.Start.gif" or just "img/toolbar.Start.gif". Of course, make sure the sub-directory "img" is in the same directory where you have the page file with this code. In other words, use relative paths; relative to the location of the page using them.

—SA


以下链接将使您清楚:
http://msdn.microsoft.com/en-us/library/ms178116.aspx [ ^ ]
http://www.informit.com/articles/article.aspx?p=101145& seqNum = 2 [ ^ ]
The following links will make you clear:
http://msdn.microsoft.com/en-us/library/ms178116.aspx[^]
http://www.informit.com/articles/article.aspx?p=101145&seqNum=2[^]


路径似乎错误.解决此问题的最简单方法是,右键单击页面上的红十字图标"(由于无效路径而来),然后检查采用的路径.从那里您将能够了解问题所在. :)
The path is seems to be wrong. The easiest way to resolve this, Right click on the "Red Cross Icon" on the page ( Which is coming due to invalid path ) and check the what path it is taken. From there you will able to understand what is wrong. :)


这篇关于如何从文件夹内的ASP.NET页访问图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆