I'm attempting to programmaticall y build up some HTML in the code
behind. Like so:
// Create Hyperlink
HyperLink link = new HyperLink();
link.NavigateUr l = "nice cat";
link.Text = "Cats Sleeping";
//Create Image
Image img = new Image();
img.ImageUrl = "http://www.cats.org.uk/images/lhstop_home2.jp g";
//Add image nested in the hyperlink
link.Controls.A dd(img);
//Add the link with it's controls to a placeholder
PlaceHolder1.Co ntrols.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.NavigateUr l = "nice cat";
link.Text = "Cats Sleeping";
//Create Image
Image img = new Image();
img.ImageUrl = "http://www.cats.org.uk/images/lhstop_home2.jp g";
//Add image nested in the hyperlink
link.Controls.A dd(img);
//Add the link with it's controls to a placeholder
PlaceHolder1.Co ntrols.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?
Comment