@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.
Member
29 Points
127 Posts
Hyperlink colors in a class
Oct 10, 2019 11:35 PM|Baze72|LINK
How can I make the hyperlinks the same color as the class I am assigning? They are always the default blue..
Thanks!
EB
Contributor
3140 Points
983 Posts
Re: Hyperlink colors in a class
Oct 11, 2019 03:01 AM|Yang Shen|LINK
Hi Baze72,
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:
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