5,423,696 members and growing! (17,972 online)
Email Password   helpLost your password?
Enterprise Systems » SharePoint Server » Custom Controls     Intermediate License: The Code Project Open License (CPOL)

Navigation Custom Control for Microsoft Office SharePoint Server (MOSS)

By Stephen Huen

Renders navigational nodes using list tags.
C#, Windows, .NET 2.0, .NET, ASP.NET, Visual Studio, VS2005, Dev

Posted: 7 Dec 2006
Updated: 24 Apr 2008
Views: 39,923
Bookmarked: 17 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
4 votes for this Article.
Popularity: 2.50 Rating: 4.16 out of 5
1 vote, 25.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
0 votes, 0.0%
4
3 votes, 75.0%
5

Introduction

For use in the 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.
  • 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.

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

The sample Visual Studio 2005 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.

You can install the web control using stsadm, passing to it the solution file QuestechSolution.wsp in \Deployments\Solution\:

stsadm -o addsolution -filename QuestechSolution.wsp

Then, go to SharePoint Central Administration/Operations/Global Configuration-Solution Management and deploy the 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:

...
<%@ Register Tagprefix="QuestechPublishingWebControls"
    Namespace="QuestechSystems.SharePoint.Publishing.WebControls"
    Assembly="QuestechSystems.SharePoint.Publishing, Version=1.0.0.0, 
              Culture=neutral, PublicKeyToken=6cab99363c374a89" %>
...
...
<QuestechPublishingWebControls:VerticalNavigation CompactMode="False" runat="server" />
...

History

  • 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)

About the Author

Stephen Huen



Occupation: Web Developer
Company: Questech Systems
Location: Canada Canada

Other popular SharePoint Server articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 28 (Total in Forum: 28) (Refresh)FirstPrevNext
Subject  Author Date 
QuestionCurrentNodeParentCssClass parameter not working?memberglends2:21 27 Aug '08  
AnswerRe: CurrentNodeParentCssClass parameter not working?memberStephen Huen9:44 27 Aug '08  
GeneralRe: CurrentNodeParentCssClass parameter not working? [modified]memberglends10:28 27 Aug '08  
GeneralRe: CurrentNodeParentCssClass parameter not working?memberStephen Huen21hrs 16mins ago 
GeneralRe: CurrentNodeParentCssClass parameter not working?memberglends14hrs 14mins ago 
QuestionPotentially excessive number of SPRequest objects (9) currently unreleased on thread 7memberhexiumcoza0:52 1 Aug '08  
AnswerRe: Potentially excessive number of SPRequest objects (9) currently unreleased on thread 7memberStephen Huen19:40 2 Aug '08  
GeneralRe: Potentially excessive number of SPRequest objects (9) currently unreleased on thread 7memberhexiumcoza20:42 3 Aug '08  
GeneralStyling the menumemberMember 41122290:00 21 May '08  
General"Object reference not set to an instance of an object." [modified]memberc#SPDev10:10 1 May '08  
GeneralRe: "Object reference not set to an instance of an object."memberStephen Huen7:22 4 May '08  
GeneralRemove menumemberlaytrix22:08 28 Apr '08  
GeneralRe: Remove menumemberlaytrix14:45 29 Apr '08  
GeneralRe: Remove menumemberStephen Huen20:57 30 Apr '08  
QuestionRedirecting search pagememberrahulnair12:42 25 Apr '08  
QuestionError creating controlmemberFelicia20:27 4 Feb '08  
GeneralRe: Error creating controlmemberHenrik Weimenhog5:20 29 Feb '08  
GeneralFiltering SPFieldLookup valuememberrahulnair23:53 5 Nov '07  
QuestionHow to perform some modifications in displaymemberpanjkov0:48 18 Sep '07  
AnswerRe: How to perform some modifications in displaymemberStephen Huen19:03 18 Sep '07  
GeneralRe: How to perform some modifications in displaymemberpanjkov23:48 18 Sep '07  
GeneralRe: How to perform some modifications in displaymemberpanjkov2:11 19 Sep '07  
GeneralRe: How to perform some modifications in displaymemberStephen Huen14:44 19 Sep '07  
GeneralRe: How to perform some modifications in displaymemberwin_asp0:54 21 Sep '07  
QuestionRe: How to perform some modifications in displaymemberMember 42340139:11 29 Apr '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Apr 2008
Editor: Smitha Vijayan
Copyright 2006 by Stephen Huen
Everything else Copyright © CodeProject, 1999-2008
Web19 | Advertise on the Code Project