Click here to Skip to main content
13,549,226 members
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 15 May 2010
Licenced CPOL

Navigation Custom Control (SharePoint Server 2010)

, 15 May 2010
Rate this:
Please Sign up or sign in to vote.
Renders navigational nodes in HTML list tags


For use in Microsoft SharePoint Server 2010, this web control is an alternative to the out-of-the-box "Current Navigation" a.k.a. AspMenu. It renders navigational nodes using HTML list tags, like:

This web control is adapted from my SharePoint Server 2007 version for use in SharePoint Server 2010.


The web control uses PortalSiteMapProvider to render navigation nodes. Although the SharePoint 2010 version of AspMenu supports emission of HTML list tags with the use of property UseSimpleRendering, it is still fairly rigid in how children levels are displayed when you are at the top level and when you navigate down the nodes.

It has several public properties:

  • SiteMapProvider - A site map provider of type PortalSiteMapProvider. Default is CurrentNavigation.
  • StartNodeKey - Server relative URL for a starting sub-site. For example: /PressReleases/2010. Default is the root site.
  • IncludeSubSites - Include sub-sites? Allowed values are True, False, or PerWeb. Default is PerWeb, i.e., a per sub-site setting, configurable in Site Actions > Navigation (Look and Feel).
  • IncludePages - Include pages? Allowed values are True, False, or PerWeb. Default is PerWeb, i.e., a per sub-site setting, configurable in Site Actions > Navigation (Look and Feel)
  • IncludeHeadings - Include headings? Allowed values are True, False.
  • IncludeAuthoredLinks - Include authored links? Allowed values are True, False.
  • MaxLevels - Maximum number of node levels. Default is 0, i.e., no limit.
  • CompactMode - If set to True, the navigation expands the top level nodes and all parent nodes to the current node. In the example below, nodes Child1, Child2, and Child3 are the top level nodes:
            Child211 (Current Node)

    If set to False, sibling nodes to the current node and its parent nodes will also be shown. For example:

            Child211 (Current Node)

    Default is False.

  • ListCssClass - CSS class name for the outermost <ul> tag.
  • NodeCssClass - CSS class name for regular hyperlinked nodes.
  • CurrentNodeCssClass - CSS class name for a selected node.
  • CurrentNodeParentCssClass - CSS class name for the lowest level node under which there is a selected node.
  • NoUrlNodeCssClass - CSS class name for nodes with no URL, like headings.

The control also uses a resource file to store all messages and property attribute UI strings. It demonstrates how to develop a custom class that inherits CategoryAttribute or DescriptionAttribute and returns a localized string from your own Resource Manager.

The sample Visual Studio 2010 solution includes all the support files you need to build and deploy this web control, minus the strong name key file (key.snk). It makes full use of the built-in SharePoint integration. No more third party tools or custom pre and post build scripts are needed to build the SharePoint solution file.


The web control does not fully support site hierarchy containing navigational "headings" because they cannot be clicked to open up child nodes. The navigation will, however, show parent headings if one of the child nodes is a current node.


Open SharePoint 2010 Management Shell, add solution file QuestechNavigation.wsp using Add-SPSolution like:

Add-SPSolution "C:\QuestechSystems.Navigation\bin\Release\QuestechNavigation.wsp"

Or using stsadm, add solution file QuestechNavigation.wsp like:

stsadm -o addsolution -filename 

Go to SharePoint 2010 Central Administration/System Settings/Manage farm solutions. Deploy the installed solution to selected web applications. To insert the web control to a publishing page, modify the appropriate master page or page layout as follows:

<%@ Register Tagprefix="QuestechPublishingWebControls"


    Assembly="QuestechSystems.SharePoint.Publishing.Navigation, Version=, 
              Culture=neutral, PublicKeyToken=57d955ce9c425b79" %>
<QuestechPublishingWebControls:Navigation CompactMode="False" runat="server" />


  • 15th May, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Stephen Huen
Software Developer (Senior)
Canada Canada
A Microsoft Certified Professional Developer and Technology Specialist.

Experience and expertise in SharePoint 2016 / 2013 / 2010 / 2007.

Role ranges from a developer in a multi-person team to a solution consultant with expert-level skills, leading a project to completion status.

Proven experience working effectively in a team environment and a self-managed environment.

You may also be interested in...


Comments and Discussions

QuestionStarting node offset? Pin
jomungand18-Nov-10 5:12
memberjomungand18-Nov-10 5:12 
QuestionRe: Starting node offset? Pin
Member 33236308-Aug-11 20:10
memberMember 33236308-Aug-11 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01-2016 | 2.8.180515.1 | Last Updated 15 May 2010
Article Copyright 2010 by Stephen Huen
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid