locked
Dynamically create Image Objects or Reference HTML Object in ASP Code RRS feed

  • Question

  • User1371046470 posted

     Currently I have a script that allows the user to upload an image.

    My script automatically thumbs the image. But upon thumbing the image I would like the thumbed image to be displayed to the user with-in the Web Browser. A sort of visual confirmation that their image was successfully uploaded.

     
    So I figure I could either :  Dynamically create the image object (whether it's an ASP image object or an HTML image object) ... I already know how to dynamically create the HTML image object, I just don't know how to reference it within ASP code, if at all possible.

     

    Any help is appreciated.
     

    --Chris

     

    Saturday, November 15, 2008 10:14 PM

Answers

  • User1371046470 posted

    Well yippy... I figured it out before you guys could reply!

                                 System.Web.UI.WebControls.Image imgControl = new System.Web.UI.WebControls.Image();

    //  The reason I had to declare the above using the entire NameSpace is because I've also included System.Drawing  in my application. 

    HtmlGenericControl paraContainer = new HtmlGenericControl("p");
                                paraContainer.Controls.Add(imgControl);
                                PlaceHolder1.Controls.Add(paraContainer);
                           
                                imgControl.ImageUrl = theurl;
                                imgControl.ImageAlign = System.Web.UI.WebControls.ImageAlign.Top;
                                imgControl.Height = theheight;
                                imgControl.Width = thewidth;

     

    This is the code I had to finish off with. It's working so I'm happy ;P

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 16, 2008 3:10 AM

All replies

  • User1371046470 posted

    Well yippy... I figured it out before you guys could reply!

                                 System.Web.UI.WebControls.Image imgControl = new System.Web.UI.WebControls.Image();

    //  The reason I had to declare the above using the entire NameSpace is because I've also included System.Drawing  in my application. 

    HtmlGenericControl paraContainer = new HtmlGenericControl("p");
                                paraContainer.Controls.Add(imgControl);
                                PlaceHolder1.Controls.Add(paraContainer);
                           
                                imgControl.ImageUrl = theurl;
                                imgControl.ImageAlign = System.Web.UI.WebControls.ImageAlign.Top;
                                imgControl.Height = theheight;
                                imgControl.Width = thewidth;

     

    This is the code I had to finish off with. It's working so I'm happy ;P

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 16, 2008 3:10 AM
  • User-319574463 posted

     >Well yippy... I figured it out before you guys could reply

    Excellent! (This has happended to me several times!)

    Please click the "Mark as Answer" against your second post, so we know the thread is answered.

    Thursday, November 20, 2008 9:53 AM