locked
how can i change color of link RRS feed

  • Question

  • User1331915375 posted

    i want to chang color of asp link on mouse over on this link like html link how can i do that

    Tuesday, July 31, 2007 5:44 AM

Answers

  • User-154051931 posted

    You need to use CSS to do this.  I have no idea why anybody recommended javascript!  Setup a CSS class in your <head> section like this:

        <style type="text/css">
            a.classA
            {
                color:green;
            }
    
            a.classA:hover
            {
                color:red;
            }
        </style>

     And add the class to your hyperlinks:

        <asp:HyperLink ID="HyperLink1" CssClass="classA" runat="server"
             NavigateUrl="~/test.aspx">Example Link</asp:HyperLink>
     Hope this helps!  Please mark the helpful post(s) as Answer.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 31, 2007 10:38 AM

All replies

  • User-818936891 posted

    add the attributes of this link.

     like

    link1.attributes.add("onmouseover()","linkMouseOver()")

     In the javascript function linkMouseOver, write the code for changing the color

    Tuesday, July 31, 2007 6:11 AM
  • User1331915375 posted

    thank you

    but this link in user countror and i add this in the user countrol 

    i do this

    function txtColor(){ForeColor="black";

    }

    and in user countrol load i add this :

    protected void Page_Load(object sender, EventArgs e)

    {

    BtnMenu.Attributes.Add("onmouseover", "txtColor();");

    }

    but not work [:(]

    Tuesday, July 31, 2007 8:18 AM
  • User1331915375 posted

    the funcation work if i add any java code like alert("test");

    but how can i change any propirty in asp control

    soory [:$]

    Tuesday, July 31, 2007 9:29 AM
  • User-154051931 posted

    You need to use CSS to do this.  I have no idea why anybody recommended javascript!  Setup a CSS class in your <head> section like this:

        <style type="text/css">
            a.classA
            {
                color:green;
            }
    
            a.classA:hover
            {
                color:red;
            }
        </style>

     And add the class to your hyperlinks:

        <asp:HyperLink ID="HyperLink1" CssClass="classA" runat="server"
             NavigateUrl="~/test.aspx">Example Link</asp:HyperLink>
     Hope this helps!  Please mark the helpful post(s) as Answer.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 31, 2007 10:38 AM
  • User1331915375 posted

    thanks alot sair

    Wednesday, August 1, 2007 3:56 AM
  • User-154051931 posted

    No problem.  Please mark my post as Answer since it helped you.

    Thanks...

    Wednesday, August 1, 2007 11:28 AM