Ssasidhar
Ssasidhar

Reputation: 485

Image control in asp.net?

In web application, i am trying to display image in .aspx page, for that i write code like this in page_load event ,

Image1.ImageUrl = @"C:\Users\Public\Pictures\Sample Pictures\Koala.JPEG";

but image is not displaying, can you help me thank you.

Upvotes: 1

Views: 882

Answers (2)

AMember
AMember

Reputation: 3057

You cannot use your local path as the path to your image, instead place the web site url with a relative path to the image

Upvotes: 0

Pranay Rana
Pranay Rana

Reputation: 176886

there is problem with the path of image ...you need to give relative path for image rather than physical path

something like this

Image1.ImageUrl="~/Images/Bird1.jpg"

here image is in the Images folder of the application. i.e.which is part of project

First create a Images folder in your Solution Explorer. Then store your image in that folder and refer like as below.

Example

<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Bird1.jpg" /> 

Check in deatil : Image Control Example

Upvotes: 1

Related Questions