简体   繁体   English

图像未在ASP.net visual studio 2012中显示

[英]Image not showing in ASP.net visual studio 2012

I am designing a webpage using Visual Studio 2012. When I put the following code in the source 我正在使用Visual Studio 2012设计一个网页。当我在源代码中放入以下代码时

<img src="E:\BCA\ASP.Net\Images\Questionnaire.png" />

In the design view I can see the image but when I run the page using browser the image is not visible. 在设计视图中,我可以看到图像,但是当我使用浏览器运行页面时,图像不可见。 Sometimes I see a lined rectangle but Image is not visible. 有时我看到一个带衬里的矩形,但图像不可见。

You should use relative path something like 你应该使用相对路径

<img src="../Images/Questionnaire.png" />

or you can use server control like 或者您可以使用服务器控件

<asp:Image ImageUrl="~/images/Questionnaire.png" runat="server"/>

It might be security restrictions in the browser not showing content that is local on disk. 浏览器中的安全限制可能不显示磁盘上的本地内容。

You can use relative path like Amir said in his answer. 你可以像Amir在他的回答中所说的那样使用相对路径。 If you use Razor in MVC and not web forms, you can use ~ directly in the <img> tag like this: 如果你在MVC中使用Razor而不是web表单,你可以直接在<img>标签中使用~ ,如下所示:

<img src="~/Images/Questionnaire.png" />

The ~ is automatically translated to the web application root. ~自动转换为Web应用程序根目录。

you should give like this 你应该这样给

<img src="../Images/banner2.jpg" />

the "Images" is the folder in your vs where ur image "banner2.jpg is loaded already" “图片”是您的vs中的文件夹,其中“banner2.jpg已经加载”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM