#user hl:hover {
  color: BlueViolet;
  text-decoration: underline; }



<asp:HyperLink ID="hlUsername" runat="server" NavigateUrl="~/Manager/ProfileView.aspx" CssClass="hl" />

While this hyperlink is hovered, the font is underline but font color not changing. Any problem with my code?

Recommended Answers

All 5 Replies

I don't know ASP. What does the link look like? It looks like you're creating something that looks like this:

<a href="~/Manager/ProfileView.aspx" id="h1Username" class="h1">

If that's the case, you'll want to change the first line of your CSS to be: a#h1Username:hover or a.h1:hover.

it still the same displaying in black color.

@Dani-yes you are correct. Its actually ASP.NET not ASP. But anyway, the hyperlink control is rendered as an anchor element.

Here is the HTML markup produced by the code above, asuming that the Text property was not assigned in the asp.net server side code. ASP.NET server and web controls allow you to access certain properties code-behind which is really convenient.

<a id="hlUsername" class="hl" href="Manager/ProfileView.aspx"></a>

@gahhon- The selector you are using in the first examle is referencing an element with an ID="user". Where is this element? is the hyperlink within this element such as a div.

Try this full example...

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Demo</title>
    <style>
     #user .hl:hover {
     color: BlueViolet;
     text-decoration: underline;
     }
    </style>
</head>
<body>
    <form id="form1" runat="server">
       <div id="user">
             <asp:HyperLink ID="hlUsername" runat="server" NavigateUrl="~/Manager/ProfileView.aspx" CssClass="hl" Text="Profile View" />
       </div>
    </form>
</body>
</html>

If there is no #user element, change the selector to what Dani suggests above. It depends on what else is in your HTML markup, assuming there is more code that you did not include.

i did that in css but i wrote in #user.hl:hover instead of #user .hl:hover
which mean i didn't space between them thus it cause me fail to change color.
Now it work by adding a space between them. Thanks

please any one tell me how to change profile picture like facebook in Asp.net using C#

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.