469,077 Members | 1,471 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,077 developers. It's quick & easy.

Converting Image to ImageButton

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

Jan 12 '06 #1
5 2451
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));

Jan 12 '06 #2
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" <of****@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
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

Jan 12 '06 #3
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" <of****@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
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

Jan 12 '06 #4
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" <of****@gmail.com> wrote in message
news:11********************@f14g2000cwb.googlegrou ps.com...
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));

Jan 12 '06 #5
No the thing is that I want to manipulate that image with pixels etc
and then use it in an ImageButton

Jan 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ester | last post: by
1 post views Thread by Holly | last post: by
6 posts views Thread by ruca | last post: by
10 posts views Thread by Edwin Knoppert | last post: by
9 posts views Thread by tshad | last post: by
3 posts views Thread by Ganesh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.