Применить цвет к ActionLink - PullRequest
0 голосов
/ 22 мая 2018

Я пытаюсь изменить шрифт 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)

1 Ответ

0 голосов
/ 22 мая 2018

Нельзя смешивать параметры routeValues и htmlAttributes.Эти два объекта должны быть различными.

Вид

@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>
...