为 ActionLink 应用颜色

Apply color to ActionLink

我正在尝试更改 ActionLink 的字体,但是当我在它的末尾有 , null 时,我无法更改它。

我尝试过的:

@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");
    }
}

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", style = "color:red" }, null)

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", @class = "fontColor" }, null)

您不能混合使用 routeValueshtmlAttributes 参数。这两个必须是不同的对象。

查看

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new {deviceID = item.DeviceID, type = "Verification"}, new { @class = "text-red" })

CSS

.text-red {
    color: red;
}

生成的 link 如下所示:

<a class="text-red" href="/MFC_Form/VerIndex?deviceID=1&type=Verification"> Verification |</a>