Razor variable inside ActionLink
I have a variable for a CSS class value that is assigned to a variable in the view:
string aboutLinkClass = "normalLink";
This may change depending on the context. Later in the view, I call Html.ActionLink and I need to use this variable, but the following does not give the desired result:
@Html.ActionLink("About", "Index", "about", null, new {@class="@aboutLinkClass"})
It treats @aboutLinkClass as static text. so it produces:
<a class="@aboutLinkClass" href="/about">About</a>
Instead, I want it to create:
<a class="normalLink" href="/about">About</a>
What is the syntax I need to use in order to pass it correctly?
+3
source to share