Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Not working :- onmouseover="this.bgColor='gold';" please suggest







STATE
ANDHRA PRADESH
ARUNACHAL PRADESH
ASSAM
BIHAR
Posted

Try this,
onmouseover="this.style.color='gold'"
 
Share this answer
 
Comments
Member 8631599 7-Jun-13 6:38am    
gfd
CSS is the answer...

I use something like this

CSS
.mouseover:hover
{
    background-color:Yellow;
    color:Blue;
    text-decoration:none;
}
.mouseover
{
    background-color:Blue;
    color:Yellow;
    text-decoration:none;
}
 
Share this answer
 
You need to tell where you are using the onmouseover. How are the names ANDHRA PRADESH, ARUNACHAL PRADESH, ASSAM BIHAR placed in your page.

You can do that with css something like
CSS
a:hover
{
background-color:yellow;
}

<a href="/test.aspx">test</a>


Update
CSS
<style type="text/css">
.clstd
{
background-color:red;
}
/*include this in your style must work*/
.clstd:hover
{
background-color:yellow;
}
</style>


You are using a class(css) and again using inline properties. It is good to include everything in your css as all the td's are having same width, height etc. instead of writing for each of them.
 
Share this answer
 
v2
Comments
Dalek Dave 7-Apr-11 5:52am    
Damn, you beat me to it! But, yes, CSS is the best way of doing it.
Mayur Gujrathiii 7-Apr-11 6:09am    
I am doing like this
<form id="frmstatehlp" runat="server" target="stateclient">

<table align="left" class="clsborder" border="0" cellpadding="0" cellspacing="0" >
<tr class="grhd">
<th class="grhd" align="left" style="height: 17px; width:10%">STATE</th>
</tr>
<tr ondblclick="getvalues(this);" onmouseover="this.bgColor='#FFFFFF'" önmouseout="this.bgColor='gold';" >
<td class="clstd" style="height: 17px; width:10%">ANDHRA PRADESH</td>
</tr>
<tr ondblclick="getvalues(this);" onmouseout="this.bgColor='#FFFFFF'" önmouseover="this.bgColor='gold';" >
<td class="clstd" style="height: 17px; width:10%">ARUNACHAL PRADESH</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">ASSAM</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">BIHAR</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">CHATTISGARH</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">GOA</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">GUJARAT</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">HARYANA</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">HIMACHAL PRADESH</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">JAMMU AND KASHMIR</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">JHARKHAND</td>
</tr>
<tr öndblclick="getvalues(this);" >
<td class="clstd" style="height: 17px; width:10%">KARNATAKA</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">KERALA</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">MADHYA PRADESH</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px; width:10%">MAHARASHTRA</td>
</tr>
<tr ondblclick="getvalues(this);" önmouseout="this.bgColor='#FFFFFF'" >
<td class="clstd" style="height: 17px;
Smithers-Jones 7-Apr-11 6:24am    
What is this önmouseout? Is it Swedish? ;-)
m@dhu 7-Apr-11 6:24am    
Check the updated answer.
You can also do this by binding attribute of Textbox take a look
// It will change color of text on mouse over
TextBox1.Attributes.Add("onmouseover", "javascript:this.style.color='gold'");


//Color on mouseout event 
  TextBox1.Attributes.Add("onmouseout","javascript:this.style.color='black'");


[Edited]
hmm! It's my mistake that I was taking question as change color of text of textbox on mouseover
You should follow the answer of Toniyo , Dalek as well as MKgoud if you will have to change text of control then my Idea will work.
In short you need to use
onmouseover="this.style.color='gold'" instead of onmouseover="this.bgColor='gold';"
[/Edited]
 
Share this answer
 
v2
onclientclick call a javascript function.and there you can add classname of that particularcontrol.
like below:
JavaScript:
function colorchange()
{
   var ctlid=document.getelementbyid('<%=contorlid.ClientID %>');
   ctl.ClassName="mouseoverColorchange";
}

css:
mouseoverColorchange{
    background-color:Blue;    
color:Yellow;    
text-decoration:none;
}

now call the javascript function(). I think it will work
 
Share this answer
 
v2
Comments
Toniyo Jackson 7-Apr-11 6:40am    
Pre tag added for code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900