I am currently working on a web page that involves a file upload controller for images.
<img src='#' id='imageId' alt='your image' height='64' width='64' src='placeholder.png' class='placeholder' >
<input type='file' id='myID' onchange='previewImage(this)' accept='image/*' data-thumbnail='imageId'>
The HTML code above is converted from my existing asp code.
Now, I am trying to manually generate these two components using C# coding. Here's how I started:
System.Web.UI.WebControls.Image preview = new System.Web.UI.WebControls.Image();
preview.ID = "imageId";
preview.Height = 64;
preview.Width = 64;
FileUpload tt = new FileUpload();
tt.ID = "myID";
However, there are some attributes in the original HTML code that I am unsure how to implement with C# code.
I also need to handle the "onchange" event of the File upload control, which triggers the javascript function 'previewImage(this)' to preview the selected image.
Please assist me in figuring out how to achieve these tasks using C# code.