Solved

MouseOver Effects using ASP.NET

Posted on 2004-04-19
8
731 Views
Last Modified: 2012-08-13
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?
0
Comment
Question by:bchia
8 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 10857820
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
 
LVL 8

Expert Comment

by:Dishan Fernando
ID: 10857826
You must do it through java script
0
 

Author Comment

by:bchia
ID: 10857841
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 28

Accepted Solution

by:
mmarinov earned 20 total points
ID: 10857849
<script language=javascript>
 function changeimage(src)
 {
  imagebuttonname.src = src;
 }
</script>

B..M
0
 
LVL 8

Expert Comment

by:Dishan Fernando
ID: 10857856
0
 
LVL 6

Expert Comment

by:zulu_11
ID: 10859111
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

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question