Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a webform with 3 buttons and an image control.

I would like to show an image in the image control when I move the over the 3 buttons. Each button should show a different image. How can I do that?


Regards
Scorgi
Posted

Lots of examples online on how to to rollover images. For example, this is the first from a google search I did:

http://helplogger.blogspot.com/2012/05/create-rollover-image-effect-change.html[^]
 
Share this answer
 
Comments
Member 11971472 6-Oct-15 8:56am    
I would like to make a button rollover to show an image and not image rollover.
ZurdoDev 6-Oct-15 9:04am    
You have lots of options. Change your button to an image that is clickable and looks like a button then just change the src as in the example.

Or, use jquery to do the change.
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function showimage1() {
document.getElementById("Image1").style.display = "inline";
document.getElementById("Image1").src = 'add_icon.png';

}
//you can write for other buttons as well
function hideimage() {
document.getElementById("Image1").style.display = "none";
}
</script>
</head>
<body>
<form id="form1" runat="server">

<asp:Button ID="Button1" runat="server" Text="Button" onmouseover="showimage1();" onmouseout="hideimage()"/>
<asp:Image ID="Image1" runat="server" />

</form>
</body>
</html>
 
Share this answer
 
v2
Comments
Member 11971472 6-Oct-15 9:58am    
Thanks for all answers. Would like to use this solution, but where do I put the C# code on the webform?

Thanks for helping me out
Member 12003400 6-Oct-15 9:59am    
put in pageload event
Member 11971472 7-Oct-15 2:12am    
I did and nothing happens.
Member 12003400 7-Oct-15 2:44am    
Any error?
Member 11971472 7-Oct-15 2:51am    
no but nothing showing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900