@{ var actionName = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(); }
<div class="@(actionName == "AddQuestion" ? "selectedItem" : "unselectedItem")">
@Html.ActionLink("Add a Question", "AddQuestion", new { topicId = ViewBag.topicId })</div>
<div class="@(actionName == "AddSubTopic" ? "selectedItem" : "unselectedItem")">
...
но, вероятно, было бы чище создать HtmlHelper
public static HtmlString CssClassForAction(this HtmlHelper helper, string action) {
var actionName = helper.ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
return new HtmlString(actionName == action ? "selectedItem" : "unselectedItem");
}
и по вашему мнению
<div class="@Html.CssClassForAction("AddQuestion")">
@Html.ActionLink("Add a Question", "AddQuestion", new { topicId = ViewBag.topicId })</div>
<div class="@Html.CssClassForAction("AddSubTopic")">
...