Click here to Skip to main content
15,868,419 members
Articles / Web Development / ASP.NET

Navigation Custom Control for Microsoft Office SharePoint Server (MOSS)

Rate me:
Please Sign up or sign in to vote.
4.21/5 (9 votes)
13 May 2010CPOL3 min read 213.8K   887   55   48
Renders navigational nodes using list tags

Introduction

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

Description

The web control uses a PortalSiteMapProvider to render a vertical navigation. Unlike the out-of-the-box AspMenu, it does not emit table tags, but list tags customizable using CSS classes. The navigation expands the root nodes and sibling nodes to the current node and its parent nodes. A node can be a sub-site or a page.

It has several public properties:

  • SiteMapProvider - A site map provider of type PortalSiteMapProvider. Default is CurrentNavSiteMapProvider.
  • StartNodeKey - Server relative URL for a starting sub-site. For example: /PressReleases/2006. 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 the Modify Navigation Site Actions menu.
  • IncludePages - Include pages? Allowed values are True, False, or PerWeb. Default is PerWeb, i.e., a per sub-site setting, configurable in the Modify Navigation Site Actions menu.
  • 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 root nodes and all parent nodes to the current node. In the example below, nodes Child1, Child2, and Child3 are the root nodes:
  • Child1
    Child2
        Child21
            Child211 (Current Node)
                Child2111
    Child3
    

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

    Child1
    Child2
        Child21
            Child211 (Current Node)
                Child2111
            Child212
        Child22
        Child23
    Child3
    

    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 2008 solution includes all the support files you need to build and deploy this web control, minus strong name key files (*.snk). It contains two projects: Deployment and SharePoint.Publishing. The SharePoint.Publishing project contains source codes for the web control. The Deployment project contains a Solution directory where a WSP file is generated and deployed by a post-build script.

Notes

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.

Installation

Using stsadm, install solution file QuestechNavigation.wsp in \Deployments\Solution\:

stsadm -o addsolution -filename QuestechNavigation.wsp

Go to SharePoint Central Administration/Operations/Global Configuration-Solution Management. Deploy the installed solution to the selected web applications. To insert the web control to a publishing page, modify the appropriate master page or page layout as follows:

ASP.NET
...
<%@ Register Tagprefix="QuestechPublishingWebControls"
    Namespace="QuestechSystems.SharePoint.Publishing.WebControls"
    Assembly="QuestechSystems.SharePoint.Publishing.Navigation, Version=1.0.0.0, 
              Culture=neutral, PublicKeyToken=57d955ce9c425b79" %>
...
...
<QuestechPublishingWebControls:Navigation CompactMode="False" runat="server" />
...

History

  • V1.4 - 2010.05.12
    • Removed empty ul tags for expandable nodes that are not expanded
  • V1.3 - 2009.05.22
    • Converted Visual Studio solution projects to version 2008
    • New SharePoint Solution QuestechNavigation.wsp and assembly QuestechSystems.SharePoint.Publishing.Navigation.dll. This allows my other sample solutions in CodeProject to co-exist with this web control.
    • Renamed class from VerticalNavigation to Navigation
  • V1.2 - 2008.04.21
    • Added new property CompactMode
    • Included sample Visual Studio 2005 solution for compiling and deploying the web control
    • Updated installation instructions
  • V1.1 - 2007.09.18
    • Added new properties SiteMapProvider, IncludeSubSites, and IncludePages
    • Added rendering of sibling nodes if current node is a page or a sub-site with default page only
    • Added resource file for property attribute UI strings and error messages
  • V1.0 - 2006.12.07 - Base

License

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


Written By
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.

Comments and Discussions

 
SuggestionShow All Children Nodes from anywhere Pin
Member 1039661426-Feb-14 6:02
Member 1039661426-Feb-14 6:02 
GeneralMy vote of 5 Pin
vchatakondu7-May-12 7:28
vchatakondu7-May-12 7:28 
GeneralSharePoint Server 2010 version ... Pin
Stephen Huen27-Jul-10 12:36
Stephen Huen27-Jul-10 12:36 
Questionhow to eliminate empty ULs Pin
Andreas Boehmer1-Oct-09 14:31
Andreas Boehmer1-Oct-09 14:31 
GeneralHaving difficulty using Pin
vynsane2-Sep-09 8:40
vynsane2-Sep-09 8:40 
GeneralHi Pin
Chinmoyee12-May-09 23:10
Chinmoyee12-May-09 23:10 
QuestionHow to get current navigation for the startnodekey Pin
nareshveeragoni26-Mar-09 10:36
nareshveeragoni26-Mar-09 10:36 
QuestionRe: How to get current navigation for the startnodekey Pin
Andreas Boehmer7-Sep-09 13:26
Andreas Boehmer7-Sep-09 13:26 
AnswerRe: How to get current navigation for the startnodekey Pin
Andreas Boehmer1-Oct-09 15:00
Andreas Boehmer1-Oct-09 15:00 
Questionchange the top level site node background to tabbed clors Pin
nareshveeragoni26-Mar-09 10:17
nareshveeragoni26-Mar-09 10:17 
Questionhow to identify each level of sites so that we can add css based on the level Pin
nareshveeragoni26-Mar-09 10:11
nareshveeragoni26-Mar-09 10:11 
AnswerRe: how to identify each level of sites so that we can add css based on the level Pin
panjkov15-Apr-09 4:56
panjkov15-Apr-09 4:56 
QuestionHow do i change bullets and remove the spacing before the bullets Pin
nareshveeragoni23-Mar-09 14:03
nareshveeragoni23-Mar-09 14:03 
QuestionHow to set HoverStyle Pin
SimonAmrein7-Nov-08 2:45
SimonAmrein7-Nov-08 2:45 
QuestionSite Navigation Control Pin
hiteshd14-Oct-08 11:40
hiteshd14-Oct-08 11:40 
AnswerRe: Site Navigation Control Pin
Stephen Huen15-Oct-08 7:36
Stephen Huen15-Oct-08 7:36 
GeneralRe: Site Navigation Control Pin
hiteshd16-Oct-08 10:44
hiteshd16-Oct-08 10:44 
QuestionError loading project Pin
spprashaant5-Sep-08 16:06
spprashaant5-Sep-08 16:06 
QuestionRe: Error loading project Pin
spprashaant5-Sep-08 18:33
spprashaant5-Sep-08 18:33 
AnswerRe: Error loading project Pin
Stephen Huen6-Sep-08 22:19
Stephen Huen6-Sep-08 22:19 
QuestionCurrentNodeParentCssClass parameter not working? Pin
glends27-Aug-08 1:21
glends27-Aug-08 1:21 
AnswerRe: CurrentNodeParentCssClass parameter not working? Pin
Stephen Huen27-Aug-08 8:44
Stephen Huen27-Aug-08 8:44 
GeneralRe: CurrentNodeParentCssClass parameter not working? [modified] Pin
glends27-Aug-08 9:28
glends27-Aug-08 9:28 
GeneralRe: CurrentNodeParentCssClass parameter not working? Pin
Stephen Huen27-Aug-08 13:17
Stephen Huen27-Aug-08 13:17 
GeneralRe: CurrentNodeParentCssClass parameter not working? Pin
glends27-Aug-08 20:19
glends27-Aug-08 20:19 

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.