How do I dynamically create an image on my form?

Discussion in 'ASP .Net Web Controls' started by Robson Carvalho Machado, Aug 7, 2004.

  1. Dear friends,

    Does anybody can help me with dynamically creation of an image on my form?
    I'm using the following code to create an ImageButom but it does not work
    with single Image.

    What do I need to do?

    Dim myImageButton as ImageButton
    myImageButton = New ImageButton
    myImageButton.ID = "ImageButton1"
    myImageButton.ImageUrl = "http://localhost/img.gif"
    PlaceHolder1.Controls.Add(myImageButton)

    When I try the following code it does not work:

    Dim myImage as Image
    myImage = New Image
    myImage.ID = "Image1"
    myImage.ImageUrl = "http://localhost/img.gif"
    PlaceHolder1.Controls.Add(myImage)
     
    Robson Carvalho Machado, Aug 7, 2004
    #1
    1. Advertising

  2. Dear friends,

    A friend on this communit has already answered my question.

    SOLUTION
    -------------
    Dim myImage as WebControls.Image
    myImage = New WebControls.Image
    myImage.ImageUrl = ImageUrl
    myImg.Width = Unit.Pixel(100)
    img.Height = Unit.Pixel(100)
    PlaceHolder1.Controls.Add(myImage)

    "Robson Carvalho Machado" wrote:

    > Dear friends,
    >
    > Does anybody can help me with dynamically creation of an image on my form?
    > I'm using the following code to create an ImageButom but it does not work
    > with single Image.
    >
    > What do I need to do?
    >
    > Dim myImageButton as ImageButton
    > myImageButton = New ImageButton
    > myImageButton.ID = "ImageButton1"
    > myImageButton.ImageUrl = "http://localhost/img.gif"
    > PlaceHolder1.Controls.Add(myImageButton)
    >
    > When I try the following code it does not work:
    >
    > Dim myImage as Image
    > myImage = New Image
    > myImage.ID = "Image1"
    > myImage.ImageUrl = "http://localhost/img.gif"
    > PlaceHolder1.Controls.Add(myImage)
    >
    >
     
    Robson Carvalho Machado, Aug 8, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Ternier

    Dynamically create form with .NEt controls

    Ryan Ternier, Dec 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    Ryan Ternier
    Dec 14, 2004
  2. =?Utf-8?B?ZGF2aWQ=?=

    How dynamically declare Image controls in a web form?

    =?Utf-8?B?ZGF2aWQ=?=, Jan 9, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,775
    =?Utf-8?B?ZGF2aWQ=?=
    Jan 9, 2006
  3. Replies:
    4
    Views:
    7,580
    Petulka77
    Nov 29, 2007
  4. Gino Perruti
    Replies:
    1
    Views:
    1,165
    Jon Paal
    Oct 5, 2006
  5. Replies:
    1
    Views:
    1,141
    Phillip Williams
    Dec 22, 2005
Loading...

Share This Page