将颜色应用于ActionLink

时间:2018-05-22 14:23:58

标签: css asp.net-mvc actionlink

我正在尝试更改250000的字体,但是当我在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)

1 个答案:

答案 0 :(得分:1)

您无法混合routeValueshtmlAttributes参数。这两个必须是不同的对象。

查看

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

<强> CSS

.text-red {
    color: red;
}

生成的链接如下所示:

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