I am trying to change the font of a ActionLink
, however I cannot get it to change when I have , null
at the end of it.
What I have tried:
@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", id = "Color" }, null)
window.onload = function () {
var x = "fontColor";
alert("color " + x);
if (x == "fontColor") {
$("#Color").css('color', "red");
}
else {
$("#Color").css('color', "green");
}
}
and
@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", style = "color:red" }, null)
and
@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", @class = "fontColor" }, null)
You cannot mix the routeValues
and htmlAttributes
parameters. These two must be distinct objects.
View
@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new {deviceID = item.DeviceID, type = "Verification"}, new { @class = "text-red" })
CSS
.text-red {
color: red;
}
The generated link looks like this:
<a class="text-red" href="/MFC_Form/VerIndex?deviceID=1&type=Verification"> Verification |</a>