Load Image from codebehind

G

Guest

HI Guys, I need to load image in table cell from codebehind.

i have the following code:

TableRow tRow = new TableRow();
Table2.Rows.Add(tRow);
TableCell tCell1= new TableCell();
if (property[4].Value.ToString()=="1")
{
tCell1.Image="test";
}

tRow.Cells.Add(tCell1);

Thanks in advance
Manny
 
K

Kikoz

Hi.

System.Web.UI.WebControls.Image img = new Image();
img.ImageUrl = "/folder/blah_blah.gif";
img.Height = Unit.Pixels(20);
// Bunch of other "html like" properties are available for this type
//Or you can use img.Attributes collection to insert your own html/script
events attributes like this:
img.Attributes["onclick"] = "alert('Whatever');return false;";
//Then
tCell1.Controls.Add(img);
//End of story


Regards,
Kikoz
 
G

Guest

Thank you. Will give this a try.

Kikoz said:
Hi.

System.Web.UI.WebControls.Image img = new Image();
img.ImageUrl = "/folder/blah_blah.gif";
img.Height = Unit.Pixels(20);
// Bunch of other "html like" properties are available for this type
//Or you can use img.Attributes collection to insert your own html/script
events attributes like this:
img.Attributes["onclick"] = "alert('Whatever');return false;";
//Then
tCell1.Controls.Add(img);
//End of story


Regards,
Kikoz


Manny Chohan said:
HI Guys, I need to load image in table cell from codebehind.

i have the following code:

TableRow tRow = new TableRow();
Table2.Rows.Add(tRow);
TableCell tCell1= new TableCell();
if (property[4].Value.ToString()=="1")
{
tCell1.Image="test";
}

tRow.Cells.Add(tCell1);

Thanks in advance
Manny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top