| | |
Change backColor of Button When Mouse Move over it
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 33
Reputation:
Solved Threads: 1
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-
As we change the backcolor of td, when we moves move over it.Eg Below-
ASP.NET Syntax (Toggle Plain Text)
<td onMouseOver="this.bgColor='#00CC00'" onMouseOut="this.bgColor='#009900'" bgColor=#009900 style="width: 33px; height: 81px"> </td>
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 118
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.
Due to lack of freedom of speech, i no longer post on this website.
•
•
Join Date: Aug 2009
Posts: 19
Reputation:
Solved Threads: 2
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>
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>
•
•
Join Date: Apr 2009
Posts: 33
Reputation:
Solved Threads: 1
hi praveen your code work correctly,But its lengthy...But thx
Other Way of Doing it -
Other Way of Doing it -
ASP.NET Syntax (Toggle Plain Text)
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'"); }
![]() |
Similar Threads
- Change BackColor of Entire Application (C#)
- Flash - Animated Button? (Graphics and Multimedia)
- How to change a Cancel button to OK button? (C++)
- Generating a Random Number (C#)
- Change BackColor of CommandButton at Runtime (VB.NET)
- More font styles in a button caption (Pascal and Delphi)
- Simulate Mouse Move (C++)
Other Threads in the ASP.NET Forum
- Previous Thread: ajaxtool kit error
- Next Thread: Read unknown word in string.
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox click commonfunctions compatible confirmationcodegeneration content contenttype courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview gridview homeedition iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration nameisnotdeclared news numerical objects order panelmasterpagebuttoncontrols radio ratings reportemail rotatepage save schoolproject search security serializesmo.table silverlight smartcard software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice xml youareanotmemberofthedebuggerusers






