0

In my asp.net application, there is a hyperlink. I want to change it's color to white when I hover over it using css, but it is not working.

<asp:HyperLink ID="hlViewItem" class="hplClass" runat="server"  NavigateUrl='<%#Eval("Pro_Id","ProductDetails.aspx?ProID={0}") %>' ForeColor="#33ccff">View Item</asp:HyperLink>

My css:

.hplClass:hover
{
    color:white;
}
1
  • See this ASP.Net question to learn more on CSSClass in ASP.Net. Commented Mar 4, 2014 at 20:56

2 Answers 2

2

For ASP.NET controls use attribute CssClass instead of 'class'.

Sign up to request clarification or add additional context in comments.

4 Comments

now i have edited my code, but still not working <asp:HyperLink ID="hlViewItem" CssClass="hplClass" runat="server" NavigateUrl='<%#Eval("Pro_Id","ProductDetails.aspx?ProID={0}") %>' ForeColor="#33ccff">View Item</asp:HyperLink>
Does the rendered HTML contain class="hplClass"?
yes. after viewing source , i got this <a id="ContentBodyPlace_dlLatestItem_hlViewItem_2" class="hplClass" href="ProductDetails.aspx?ProID=4" style="color:#33CCFF;">View Item</a>
Then you should look elsewhere. Perhaps your CSS is not getting loaded. If you put <style>.hplClass:hover { color: white; }</style> just before your control, that should make sure CSS is there. If that works, see why the CSS is not loading from where you had it before.
1

Try this (After removing ForeColor="#33ccff") :

<asp:HyperLink ID="hlViewItem" CssClass="hplClass" runat="server"  NavigateUrl='<%#Eval("Pro_Id","ProductDetails.aspx?ProID={0}") %>'>View Item</asp:HyperLink>

Also make sure that you have added the reference of css file in your aspx page.

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.