Converting Image to ImageButton

V

Varangian

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
 
G

Guest

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?
 
V

Varangian

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));
 
G

George Ter-Saakov

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.
 
S

S. Justin Gengo [MCP]

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
 
B

Bruce Barker

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)
 
V

Varangian

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

Guest

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top