Belal Khan
Belal Khan

Reputation: 2119

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.

Upvotes: 0

Views: 8244

Answers (3)

Ankit Shrivastava
Ankit Shrivastava

Reputation: 1

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"

Upvotes: 0

awe
awe

Reputation: 22442

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.

Upvotes: 0

Amir Ismail
Amir Ismail

Reputation: 3883

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"/>

Upvotes: 2

Related Questions