Converting Image to ImageButton

Discussion in 'ASP .Net' started by Varangian, Jan 12, 2006.

  1. Varangian

    Varangian Guest

    Hi there experts,

    Is there a way to convert a System.Drawing.Image to an ImageButton.
    Maybe using ChangeType I don't know!

    Thank you
     
    Varangian, Jan 12, 2006
    #1
    1. Advertising

  2. Varangian

    Spam Catcher Guest

    "Varangian" <> wrote in news:1137076719.526844.90480
    @g14g2000cwa.googlegroups.com:

    > Hi there experts,
    >
    > Is there a way to convert a System.Drawing.Image to an ImageButton.
    > Maybe using ChangeType I don't know!



    They're different classes, you can't just convert them.

    But you can always declare a new ImageButton and assign the Image to the
    ImageButton?


    --
    Stan Kee ()
     
    Spam Catcher, Jan 12, 2006
    #2
    1. Advertising

  3. Varangian

    Varangian Guest

    No I can't. I specifically need that System.Drawing.Image object and
    then apply it to an ImageButton

    I'm trying to use these lines of code currently! What I am doing wrong,
    I'm getting error "Object must implement IConvertible"... what is meant
    by that error?

    const string url = @"c:\Inetpub\wwwroot\pagerror.gif";
    object image = System.Drawing.Image.FromFile(url);
    object test = (ImageButton)System.Convert.ChangeType(image,
    typeof(ImageButton));
     
    Varangian, Jan 12, 2006
    #3
  4. Sounds the same as if you said "How can I convert a brush to doorbell"
    Even that does not show how far away those 2 objects are.

    Most likely you need to rephrase it since I doubt that you want that.

    George.




    "Varangian" <> wrote in message
    news:...
    > Hi there experts,
    >
    > Is there a way to convert a System.Drawing.Image to an ImageButton.
    > Maybe using ChangeType I don't know!
    >
    > Thank you
    >
     
    George Ter-Saakov, Jan 12, 2006
    #4
  5. Varangian,

    No, you can't do that. But what do you want to do with the image once you
    have it? Are you trying to dynamically create an image and then attach it to
    an image button? You can do that by creating the image, saving it to the
    file system and then setting the image button's image source.

    Let us know exactly what your end result needs to be and I'm sure we'll be
    able to help you get there.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Varangian" <> wrote in message
    news:...
    > Hi there experts,
    >
    > Is there a way to convert a System.Drawing.Image to an ImageButton.
    > Maybe using ChangeType I don't know!
    >
    > Thank you
    >
     
    S. Justin Gengo [MCP], Jan 12, 2006
    #5
  6. Varangian

    Bruce Barker Guest

    you are confusing concepts. an ImageButton, is not an image, its a html
    control, with a property that refers to URL that returns an image. thus an
    image button really has no image, it renders the following html

    <input type="image" src="myimage.gif">

    in your case you probably want the src to refer to a page that returns an
    image

    <input type="image" src="myImageProducer.aspx">

    you can google for samples of aspx pages that return an image.

    -- bruce (sqlwork.com)





    "Varangian" <> wrote in message
    news:...
    > No I can't. I specifically need that System.Drawing.Image object and
    > then apply it to an ImageButton
    >
    > I'm trying to use these lines of code currently! What I am doing wrong,
    > I'm getting error "Object must implement IConvertible"... what is meant
    > by that error?
    >
    > const string url = @"c:\Inetpub\wwwroot\pagerror.gif";
    > object image = System.Drawing.Image.FromFile(url);
    > object test = (ImageButton)System.Convert.ChangeType(image,
    > typeof(ImageButton));
    >
     
    Bruce Barker, Jan 12, 2006
    #6
  7. Varangian

    Varangian Guest

    No the thing is that I want to manipulate that image with pixels etc
    and then use it in an ImageButton
     
    Varangian, Jan 16, 2006
    #7
  8. Varangian

    Spam Catcher Guest

    "Varangian" <> wrote in news:1137439646.029087.105410
    @o13g2000cwo.googlegroups.com:

    > No the thing is that I want to manipulate that image with pixels etc
    > and then use it in an ImageButton



    You'll need to stream the image to the image button via a second webpage.

    So rather than linking to a .gif or .jpg file, you'll like to a .aspx file
    which in actually streams the graphic's content.



    --
    Stan Kee ()
     
    Spam Catcher, Jan 17, 2006
    #8
    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. ganesh kolappan

    image/imagebutton client validation

    ganesh kolappan, Jul 3, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    502
    David Waz...
    Jul 3, 2003
  2. RobertH
    Replies:
    3
    Views:
    4,820
    RobertH
    Feb 17, 2004
  3. Jason

    Image & ImageButton controls

    Jason, Jun 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    389
    Jason
    Jun 13, 2004
  4. Jason

    Image & ImageButton controls

    Jason, Jun 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    317
    Jason
    Jun 13, 2004
  5. Jason

    Image/ImageButton Help

    Jason, Jun 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    354
    Natty Gur
    Jun 15, 2004
Loading...

Share This Page