How could I dynamically change the css of a actionLink control on CSHTML page. Suppose, I am getting a "type" parameter on the CSHTML page and on this "type" parameter basis I want to change the css of "ActionLink" on a CSHTML page. Please suggest.
2 Answers
Try This :
if(type == "somevalue")
{
@Html.ActionLink("click here","index","Home", null ,new{ @class="myclass" })
}
else
{
@Html.ActionLink("click here","index","Home", null ,new{ @class="otherclass" })
}
OR
@Html.ActionLink("click here","index","Home", null ,new{ @class = (type == "somevalue" ? "myclass" : "otherclass") })