Mr_Shaw
asked on
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?
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
/>
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?
you can write javascript for doing this
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
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
in the server side code
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.
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.
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.
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.
ASKER
yes i get your point, please continue
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.