Skip to content

Instantly share code, notes, and snippets.

@mimetaur
Created October 25, 2010 21:43
Show Gist options
  • Save mimetaur/645842 to your computer and use it in GitHub Desktop.
Save mimetaur/645842 to your computer and use it in GitHub Desktop.
C# helper to return the controller name, action name, and a combination of the two (based on haml's page_class helper)
public static string PageCssClass(this HtmlHelper helper, string seperator="-")
{
string names = String.Format("{0} {1} {0}{2}{1}",
helper.ViewContext.RouteData.Values["Controller"],
helper.ViewContext.RouteData.Values["Action"],
seperator);
return names.ToLower();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment