Created
April 24, 2015 13:57
-
-
Save Warrenn/ccee1263216d4f600080 to your computer and use it in GitHub Desktop.
Display Context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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