Click here to Skip to main content
15,905,682 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Button2.Attributes.Add("onmouseover", "this.style.cursor='wait'");
Button2.Attributes.Add("onmouseover", "this.style.backgroundColor='#FF3399'");
Button2.Attributes.Add("onmouseout", "this.style.backgroundColor='Black'");


By this code only color changes but cursor not changes
Posted

Try this,
C#
Button2.Attributes.Add("onmouseover", "this.style.cursor=pointer");
// this.style.cursor=hand (try it as well, I'm not sure about it though)

Rather I'd prefer CSS over here. See below,
CSS
.btn
{
}

.btn : hover
{
    cursor: pointer;
}

and your buttons in .aspx file
C#
<asp:button id="Button2" runat="server" cssclass="btn" text="Click Me !!" xmlns:asp="#unknown" />

-KR
 
Share this answer
 
Its because your code overwrites other 2 attributes.
Use CSS to do so.

Add the following code to you aspx or html page.
CSS
<style>
   .btn :hover
   {
     cursor:wait;
     backgroud-color:#ff3399;
     color:black; 
   }
</style>


Add this css class to your button

C#
Button2.Attributes.Add("class", "btn");
 
Share this answer
 
v2

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