Kasun Lee

Kasun Lee

  • NA
  • 178
  • 14.2k

Inserting an Image to webpage programatically, at runtime.

Aug 23 2018 11:41 PM
Hi!
 
I'm trying to intsert an image to a Windows Form > Webpage  project. I tried to insert an Image control to webpage and assign the image to the control:
  1. Image1.ImageUrl = "1.jpg"
 And I tried creating the Image on the run, and asignning it the jpg image:
  1. Image image = new Image();  
  2.             image.ID = "image1";  
  3.             image.ImageUrl = "1.jpg";  
  4.             image.ImageAlign = ImageAlign.AbsMiddle;  
  5.             image.Visible = true;  
  6.   
  7.             Form.Controls.Add(image); 
 Nothing worked so far. What I'm doing wrong? (Images are both in bin and the project directories)
Thank you.

Answers (2)