MouseOver Effects using ASP.NET

Hi how do you do mouseover effect on a button in a form?

When you put ur mouse over the button image (but1.gif), I want it to change to another button image (but2.gif). I tried onmouseover, but ASP.NET doesnt recognise it.

My current code is:

<asp:ImageButton OnClick="SubmitHandler" Runat="server" BorderWidth="0" ImageUrl="but1.gif" />

How should I manipulate it so it does the mouseover effect?
bchiaAsked:
Who is Participating?
 
mmarinovConnect With a Mentor Commented:
<script language=javascript>
 function changeimage(src)
 {
  imagebuttonname.src = src;
 }
</script>

B..M
0
 
mmarinovCommented:
add ID attribute to your ImageButton, for example ID="ImageOnMouseOver"

in your code behind
use this

ImageOnMouseOver.Attributes.Add ("onmouseover", "yourjavascript code" )

B..M

0
 
Dishan FernandoSoftware Engineer / DBACommented:
You must do it through java script
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
bchiaAuthor Commented:
Thanks heaps :)

I did what u said.. Only one more problem..
What would the javascript code be for changing image, for example, from but1.gif to but2.gif?

0
 
Dishan FernandoSoftware Engineer / DBACommented:
0
 
zulu_11Commented:
in addition to the code given by mmarinov..add another similar code for onMouseOut so that when the mouse moves away from the button , it gets back to the original image..

Zulu
0
All Courses

From novice to tech pro — start learning today.