• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3586
  • Last Modified:

Changing forecolor of LinkButton with a mouseover event

Using ASP.NET 2.0 how do you change a LinkButton's forecolor when the mouse is hovered over it?  I have seen references to CSS (Cascading Style Sheets), but I am not comfortable with them at this time.

When the mouse passes over the LinkButton I want the font to be bold then return to normal when the LinkButton loses focus.
0
Ray Turner
Asked:
Ray Turner
  • 4
  • 2
1 Solution
 
digitalZoCommented:
Add this on your Page_Load:

LinkButton1.Attributes.Add("onmouseover", "window.status='';this.style.fontWeight='bold'; return true")
0
 
digitalZoCommented:
Sorry add these two lines on your Page_Load:

LinkButton1.Attributes.Add("onmouseover", "window.status='';this.style.fontWeight='bold'; return true")
LinkButton1.Attributes.Add("onmouseout", "window.status='';this.style.fontWeight='normal'; return true")
0
 
digitalZoCommented:
Personally, I think CSS is more convenient and easier to use.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Pratima PharandeCommented:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
       <style type="text/CSS">
a {color:violet}
a:hover{color:green}
</style>
</head>
<body>
    <form id="form1"   runat="server" >
    <div>
     
        <asp:LinkButton ID="LinkButton1"  runat="server" >LinkButton</asp:LinkButton>
    </div>
    </form>
</body>
</html>


codebehind

 LinkButton1.Attributes.Add("class","myA");

refer

http://www.thescripts.com/forum/thread286900.html
0
 
Ray TurnerSenior ConsultantAuthor Commented:
How would change the font color and font weight together?
0
 
Pratima PharandeCommented:
you can hange it in style

    <style type="text/CSS">
a {color:violet}
a:hover{color:green}
</style>
0
 
digitalZoCommented:
Just add this: this.style.color='colorname'

LinkButton1.Attributes.Add("onmouseover", "window.status='';this.style.fontWeight='bold'; this.style.color='#00ff00'; return true")
LinkButton1.Attributes.Add("onmouseout", "window.status='';this.style.fontWeight='normal';this.style.color='blue'; return true")
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now