| | |
Change backColor of Button When Mouse Move over it
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
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: 123
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.
Views: 972 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net box browser button c# checkbox commonfunctions complex connection dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dropdownlist dynamically edit editing expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis javascript list listbox login microsoft migration mono mouse mssql news numerical opera panelmasterpagebuttoncontrols parent problem project radio redirect registration relationaldatabases reportemail richtextbox rows save schoolproject search security select services session silverlight smartcard smoobjects software sql sql-server sqlserver2005 suse textbox theft tracking unauthorized validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers






