How should I cleanly track selected item in ASP.NET MVC?
- by Aaron Anodide
Is there a better way to track the selected item than how I do it in the code below which implements a row of navigation links.
@Html.ActionLink(
"PreApproval",
"Summary",
new { mode = "preapproval" },
new { @class = Model.Mode == "preapproval" ? "selected" : "notselected" }) |
@Html.ActionLink(
"ActionNeeded",
"Summary",
new { mode = (string)null },
new { @class = string.IsNullOrWhiteSpace(Model.Mode) ? "selected" : "notselected" }) |
...
Should I try to encasulate the functionality of menu navigation or is this a standard approach?