Reputation: 309
I am trying to creage an image in ASP. I have tried this code but it does not work:
Image img;
protected void Page_Load(object sender, EventArgs e)
{
img = new Image();
img.ImageUrl = "~/images/numbersHorizontal.png";
img.ID = "img";
}
Upvotes: 1
Views: 1622
Reputation: 39807
Code to create image looks correct. The only part that is missing is to add newly created image to the page. Try adding this as a last line:
this.Controls.Add(img);
Upvotes: 3