tags:

views:

49

answers:

3

How can I highlight an image when it is clicked and remove the highlight when the mouse is up?

+1  A: 

Look at this highlight color on button click i think it deals with your problem

Pandiya Chendur
Actually what I want is when image is clicked highlight it and not to change is background color.
C. Karunarathne
@karuna any ex site...
Pandiya Chendur
+1  A: 

Why don't you go for CSS psuedo classes(:active,:hover), please take a look at this code.

        <div class="rollover">    
           <a href="#"><img src="Jpeg/image.gif" /></a>
        </div>
        <style type="text/css">
         <!--
            .rollover a { display:block; width:32px; background-color: #FFFFFF}
            .rollover a:hover { background-color: #990000}
            .rollover a:active { background-color: #876787}
          -->
        </style>
Srinivas Reddy Thatiparthy
Are you certain it's ASP.Net ? He hasn't tagged it like that.
Steffen
+2  A: 

Two steps:

  1. Capture Control.MouseDown Event
    • Get the current color in OldColor
    • Set the new color; and it would reflect the colored control.
    • Something like button1.BackColor = Color.Red;
  2. Capture the Control.MouseUp Event
    • Set the OldColor
KMan