A
alun65
I'm attempting to programmatically build up some HTML in the code
behind. Like so:
// Create Hyperlink
HyperLink link = new HyperLink();
link.NavigateUrl = "nice cat";
link.Text = "Cats Sleeping";
//Create Image
Image img = new Image();
img.ImageUrl = "http://www.cats.org.uk/images/lhstop_home2.jpg";
//Add image nested in the hyperlink
link.Controls.Add(img);
//Add the link with it's controls to a placeholder
PlaceHolder1.Controls.Add(link);
When I run the code I'm expecting an picture of a cat with the text
'Cats Sleeping' all enclosed in anchor tags. But instead all I get is
the image but no text. What am I doing wrong?
behind. Like so:
// Create Hyperlink
HyperLink link = new HyperLink();
link.NavigateUrl = "nice cat";
link.Text = "Cats Sleeping";
//Create Image
Image img = new Image();
img.ImageUrl = "http://www.cats.org.uk/images/lhstop_home2.jpg";
//Add image nested in the hyperlink
link.Controls.Add(img);
//Add the link with it's controls to a placeholder
PlaceHolder1.Controls.Add(link);
When I run the code I'm expecting an picture of a cat with the text
'Cats Sleeping' all enclosed in anchor tags. But instead all I get is
the image but no text. What am I doing wrong?