943,774 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 4060
  • ASP.NET RSS
Aug 27th, 2009
0

Change backColor of Button When Mouse Move over it

Expand Post »
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-
ASP.NET Syntax (Toggle Plain Text)
  1.  
  2. <td onMouseOver="this.bgColor='#00CC00'" onMouseOut="this.bgColor='#009900'" bgColor=#009900 style="width: 33px; height: 81px">
  3. </td>
Similar Threads
Reputation Points: 16
Solved Threads: 1
Light Poster
ritu verma is offline Offline
33 posts
since Apr 2009
Aug 27th, 2009
0

Re: Change backColor of Button When Mouse Move over it

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.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Aug 27th, 2009
0

Re: Change backColor of Button When Mouse Move over it

I know this could be done in CSS easily if your interested?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Enthused is offline Offline
12 posts
since Aug 2009
Aug 28th, 2009
0

Re: Change backColor of Button When Mouse Move over it

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>
Reputation Points: 10
Solved Threads: 2
Newbie Poster
praveenkumarm is offline Offline
19 posts
since Aug 2009
Aug 28th, 2009
1

Re: Change backColor of Button When Mouse Move over it

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

Other Way of Doing it -
ASP.NET Syntax (Toggle Plain Text)
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. //Button1.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'");
  4. //Button1.Attributes.Add("onmouseout", "this.style.backgroundColor='green'");
  5.  
  6.  
  7. OR
  8.  
  9. //Button1.Attributes.Add("onmouseover", "this.style.backgroundColor='#009900'");
  10. //Button1.Attributes.Add("onmouseout", "this.style.backgroundColor='#000000'");
  11. }
Reputation Points: 16
Solved Threads: 1
Light Poster
ritu verma is offline Offline
33 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: ajaxtool kit error
Next Thread in ASP.NET Forum Timeline: Read unknown word in string.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC