これを行うには、新しい Image オブジェクト変数を作成し、そのプロパティを適切に割り当ててから、ページ上の既存のオブジェクトに画像を添付します。
Image myImg = new Image();
myImg.ImageUrl = "path_of_the_image.jpg";
myImg.Visible = true;
Panel1.Controls.Add(myImg); //You can attach the image to any control on your page
または同様に:
this.Controls.Add(myImg); //Incase you wanted the image on your page controls
Label1.Controls.Add(myImg); //Incase you wanted the image to appear in a certain label
ただし、このオブジェクトは、実行するコードの寿命を超えて存続することはありません。つまり、このオブジェクトは Page_Init のスコープの後に定義されているため、後で操作することはできません。この画像を動的に追加して操作できるようにする場合は、Page_Init イベント中に追加する必要があります。