locked
Hyperlink colors in a class RRS feed

  • Question

  • User982203039 posted

    How can I make the hyperlinks the same color as the class I am assigning?  They are always the default blue..

    Thanks!
    EB

     .New {
            color: darkblue;
           
        }
    
        .In-Process {
            color: forestgreen;
        }
    
        .High {
            color: red;
            font-weight: 600
        }
                <td style="width:400px" valign="top">
                    @Html.ActionLink(item.Request, "Details", "Help", new { id = item.ID }, new { @class = "@myClass" })
                </td>

    Thursday, October 10, 2019 11:35 PM

Answers

  • User-719153870 posted

    Hi Baze72,

    Baze72

    @Html.ActionLink(item.Request, "Details", "Help", new { id = item.ID }, new { @class = "@myClass" })

    I don't think you have provide the correct class name to your @class property. And also the "@" character has special meaning in Razoe syntax, you should remove it or you will get an error message.

    Please refer to below demo which will change the hyperlink color to red:

    cshtml:

    @{
        ViewBag.Title = "Contact";
    }
    <h2>@ViewBag.Title.</h2>
    <h3>@ViewBag.Message</h3>
    <style>
        .myClass {
            color:red;
        }
        </style>
    <address>
        One Microsoft Way<br />
        Redmond, WA 98052-6399<br />
        <abbr title="Phone">P:</abbr>
        425.555.0100
    </address>
    
    <address>
        @*<strong>Support:</strong>   <a href="mailto:Support@example.com">Support@example.com</a><br />
            <strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>*@
        @Html.ActionLink("abc", "Details", "Help", new { id = "123" }, new { @class = "myClass" })
    </address>

    In the @class="XXX", XXX should be the name of your css class and with no "@" character before it.

    Here's the result:

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 11, 2019 3:01 AM