MouseUp/MouseDown events for ASP.NET ImageButton

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I want to create a pushbutton-like control on my webform that has an image
on it. I used to think that this is what the ImageButton control was, but it
seems to me that the ImageButton is nothing more than an image that can be
clicked. I have figured out a way to make the ImageButton look like a button
(there was some border property and the backgroud color). However, that
still does not make it look like it is being "pushed" the way other buttons
are. Because all I need to do to change the look between button up/button
down is change the border property, I hoped I could use the
MouseUp/MouseDown events to change this property. But for some reason the
ImageButton control does not have these events. This brings up 2 questions:

1. Why is the control called ImageButton when it does not have the same
properties or look as other types of buttons? I think a more appropriate
name would be something like HyperImage or Image Link, anything that does
not imply it acts and looks like a button.

2. What would be a good way to create the "pushing" effect of a button that
I am trying to get?

Thanks.
 
M

Mikhail Arkhipov (Microsoft)

You have to use client script and control appearance of the element on the
client. You can't use server code since up/down events do not come to the
server for performance reasons. Alternatively, you can try standard
asp:button and apply image to it using CSS background-image property via
either style or cssclass attribute.

Mikhail Arkhipov (Microsoft)
-- This post is provided 'AS IS' with no warranties and confers no rights
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top