Skip to content

Instantly share code, notes, and snippets.

@Warrenn
Created April 24, 2015 13:57
Show Gist options
  • Save Warrenn/ccee1263216d4f600080 to your computer and use it in GitHub Desktop.
Save Warrenn/ccee1263216d4f600080 to your computer and use it in GitHub Desktop.
Display Context
public static class HtmlHelperExtension
{
public static string ActiveCss<T>(this HtmlHelper helper, T pageId, string activeClass = "active")
{
var displayContext = helper.ViewData.DisplayContext<T>();
if (EqualityComparer<T>.Default.Equals(displayContext, pageId))
{
return activeClass;
}
return string.Empty;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment