简体   繁体   中英

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

<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. If you use Razor in MVC and not web forms, you can use ~ directly in the <img> tag like this:

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

The ~ is automatically translated to the web application root.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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