3

I have a button :

<div class="HeaderBarThreshold">
     <asp:LinkButton ID="SetThreshold" OnClick="btnSetThreshold_Click" runat="server">Threshold</asp:LinkButton>
</div>

I am trying to change the color of the button on mouse hover :

Here is my css :

.HeaderBarThreshold
{
    padding-left: 10px;
    font-weight: bold;
}
.HeaderBarThreshold:hover
{
    color: Red;      
}

It doesnt work somehow. Please let me know.

6 Answers 6

3

Try using the CssClass Property of ASP.NET controls. This will directly point the LinkButton itself to the CSS class, instead of having to use the div tag. For example:

<asp:LinkButton ID="SetThreshold" OnClick="btnSetThreshold_Click" runat="server" CssClass="HeaderBarThreshold">Threshold</asp:LinkButton>
Sign up to request clarification or add additional context in comments.

Comments

1

Here is a fiddle http://jsfiddle.net/zpfw7/

    .HeaderBarThreshold
    {
    padding-left: 10px;
    font-weight: bold;
    width:300px;
    height:30px;
    border:1px solid #000;
    text-align:center;
    }
    .HeaderBarThreshold:hover
    {
    color: Red; 
    background:blue;
    }

1 Comment

This does not work for an ASP.NET web form in Visual Studio 2019.
1

try this thing:

.HeaderBarThreshold a:hover
{
    color: Red;      
}

Comments

1

Add the CSS class attribute to your web control

<asp:LinkButton CSSClass="HeaderBarThreshold" ID="SetThreshold" OnClick="btnSetThreshold_Click" runat="server">Threshold</asp:LinkButton>

Also your CSS is wrong anyway because you don't have anything assigned to class "HeaderBarThreshold".

Comments

0

just try this

.HeaderBarThreshold:hover a
{
     color: Red !important; // !important may not be necessary 
}

Comments

0
.upda_link {
    font-size: 15px !important;
    color: white;
    font-weight: bolder;
}

.upda_link:hover {
    text-decoration: none;
    color: white;
}

<asp:LinkButton ID="LinkButton1" runat="server" Text="Update" CssClass="upda_link" CausesValidation="false">
</asp:LinkButton>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.