Skip to content

Instantly share code, notes, and snippets.

@motowilliams
Created May 22, 2012 22:09
Show Gist options
  • Save motowilliams/2771978 to your computer and use it in GitHub Desktop.
Save motowilliams/2771978 to your computer and use it in GitHub Desktop.
li helper to look at the requested route and add a 'selected' css class to the li tag
@helper ItemBuild(string menuItemText, string controllerName, string actionName){
var controller = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue;
var action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue;
<li @(controller.Equals(controllerName) && action.Equals(actionName) ? "class=selected" : string.Empty)>@Html.ActionLink(menuItemText, actionName, controllerName)</li>}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment