About
Pricing
Community
Teams
Start Free Trial
Log in
Mr_Shaw
asked on
3/3/2009
C# hover button with code
I am trying to do a hover feature with my button.
I have set the button up as
<asp:Button ID="Button1" runat="server" BackColor="#0099CC" BorderStyle="None"
onclick="Button1_Click" Text="Button" OnMouseEnter="Button1_Mous
eEntr" OnMouseLeave="Button1_Mous
eLve"
/>
and have the code as
private void Button1_MouseEntr(object sender, EventArgs e)
{
Button1.BackColor = System.Drawing.Color.Red;
}
but nothing is happening.
Does anybody know?
.NET Programming
ASP.NET
7
2
Last Comment
Ajay Sharma
8/22/2022 - Mon
mahadevan_v
3/3/2009
you can write javascript for doing this
mahadevan_v
3/3/2009
create 2 javascript functions
1.changes color of the button
2. resets the button to its original color
Call the functions on onmouseenter and onmouseleave events
To add the events to button use
button.Attributes.Add("onm
ouseenter"
,"function
name ");
in the server side code
Mr_Shaw
3/3/2009
ASKER
Ok... i am not the best at codeing with javascript ...
my requirement is:
to create a set of tabs using buttons.
The user passes over a button where there will be a rollover effect (change color/image).
The use then clicks the button and then it permantly changes color until another button is clicked.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Ajay Sharma
3/3/2009
There is no server side event for mouse events in asp.net.
You are calling the OnMouseEnter (which is a java script and client side event), it will not be executed on Server side.
What you have to do is either create a javascript method or use style sheets (CSS) to achieve this functionality.
If you got my point than i will clarify it further in next post.
Mr_Shaw
3/3/2009
ASKER
yes i get your point, please continue
ASKER CERTIFIED SOLUTION
mahadevan_v
3/3/2009
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Ajay Sharma
3/3/2009
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.