latha
latha

Reputation: 11

can we add image through img tag in C#.net

i want to add image through img tag in C#.net i tried the following logic but it's not work

String img+="img src="abc.jpg"

if you know plz reply me

Upvotes: 0

Views: 20753

Answers (4)

anishMarokey
anishMarokey

Reputation: 11397

Try this in .aspx page:

<asp:Image ID="Image1" runat="server"  ImageUrl=""/>

Upvotes: 1

Carlos Mu&#241;oz
Carlos Mu&#241;oz

Reputation: 17804

In .aspx

<img id="image" runat="server" />

In code behind

image.Src = "abc.jpg";

More on HtmlImage

Upvotes: 3

Sangram Nandkhile
Sangram Nandkhile

Reputation: 18192

Thats how normlly we do for html!!!

<img src="flower01.jpg" alt="Yellow Flower" width="150" height="100">

for asp we do

  <asp:Image ID="imgMain" runat="server"  ImageUrl="http://www.xyz.com/files/images/15%20Random%20Greenery.JPG"/>

can be done like this

Upvotes: 0

Cylon Cat
Cylon Cat

Reputation: 7201

In markup:

<asp:image id="myImage" runat="server" />

In code-behind:

myImage.ImageUrl = "abc.jpg";

Upvotes: 3

Related Questions