I am writing project in asp.net C#. I want to create Image programmatically by the following code:
protected void Page_Load(object sender, EventArgs e)
{
Image image = new Image();
image.ID = "image11";
image.ImageUrl = "a.jpg";
image.ImageAlign = ImageAlign.AbsMiddle;
image.Visible = true;
}
But nothing is displayed when I run the project.
How to create image from file and display it in the page by writing code in .cs file?
You have created an image control but you have not added it to your form. Write the below code to add the image control to your form.