user2320928
user2320928

Reputation: 309

Creating image in ASP.NET

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

Answers (1)

Yuriy Galanter
Yuriy Galanter

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

Related Questions