tags:

views:

105

answers:

4

Hello All, 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

+3  A: 

In markup:

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

In code-behind:

myImage.ImageUrl = "abc.jpg";
Cylon Cat
This is an <asp:Image> not a <img>
Carlos Muñoz
@Carlos, <asp:Image> generates <img> in the generated HTML. It offers more options in ASP.NET, but in terms of generated output, it accomplishes the same goal.
Cylon Cat
@Cyclon Cat: Yes I know but the question was about "img tag" therefore my answer is about it.
Carlos Muñoz
+1  A: 

In .aspx

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

In code behind

image.Src = "abc.jpg";

More on HtmlImage

Carlos Muñoz
A: 

try this in aspx page

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

hi !!

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"/&gt;

can be done like this

Sangram