0

I have button in td, I want to change the backcolor of button when the mouse move over it ..

As we change the backcolor of td, when we moves move over it.Eg Below-

<td  onMouseOver="this.bgColor='#00CC00'" onMouseOut="this.bgColor='#009900'" bgColor=#009900 style="width: 33px; height: 81px">
                                </td>
4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by ritu verma
0

you can do that with javascript, post it to javascript forum. if your button is a server control then you need its clientID to change its background color. Or if you have a specific place for the button in the TD, you can access it using the html node tree, e.g. the childNodes of the TD node. I am sorry that i am too busy to provide the sample code now.

0

Hi,
You can do it using javascript and css.
Try this code it might help.


<head runat="server">
<title>Untitled Page</title>
<style type="text/css" runat="server">
.cs
{
background-color:Window;
}
.cs1
{
background-color:ButtonFace;
}
</style>
<script type="text/javascript">
function mov()
{
var btnid= document.getElementById('btn1');
btnid.className='cs';
}
function mout()
{
var btnid= document.getElementById('btn1');
btnid.className='cs1';
}
</script>
</head>
<body>
<form id="form1" runat="server">

<input type="button" id="btn1" value="Change" onmouseover="mov()" onmouseout="mout()" runat="server" onserverclick="clk" />
</form>

1

hi praveen your code work correctly,But its lengthy...But thx

Other Way of Doing it -

protected void Page_Load(object sender, EventArgs e)
    {
        //Button1.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'");
        //Button1.Attributes.Add("onmouseout", "this.style.backgroundColor='green'");


OR

        //Button1.Attributes.Add("onmouseover", "this.style.backgroundColor='#009900'");
        //Button1.Attributes.Add("onmouseout", "this.style.backgroundColor='#000000'");
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.