Skip to content

Instantly share code, notes, and snippets.

@Dillie-O
Created May 13, 2015 22:11
Show Gist options
  • Select an option

  • Save Dillie-O/d6f2db0653d265a7bc0f to your computer and use it in GitHub Desktop.

Select an option

Save Dillie-O/d6f2db0653d265a7bc0f to your computer and use it in GitHub Desktop.
Sitefinity Navigation Active Class Helper Method
<%@ Control Language="C#" %>
<script type="text/C#" runat="server">
public static class NavHelper
{
/// <summary>
/// Returns the active class parameter if the current url contains the
/// path check specified.
/// </summary>
/// <param name="pathCheck">
/// The path slug to test against in the Url.
/// </param>
/// <returns>
/// "Active" value if path matches. Empty string if not.
/// </returns>
public static string CheckActive(string pathCheck)
{
if(HttpContext.Current.Request.Url.AbsolutePath.Contains(pathCheck))
{
return "active";
}
else
{
return "";
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment