Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
General Reference
Sites and Pages
 Using a Custom Data Source for Navi...

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Using a Custom Data Source for Navigation

Through the Microsoft.SharePoint.WebControls.DelegateControl class, you can specify a custom data source control to provide nodes for Quick Launch navigation. The control that you specify through your delegate control candidate determines which provider to use as the data source for Quick Launch, which can be located in a database or in code. This type of customization changes the nodes that are displayed without modifying the way links are displayed.

You can replace the default nodes used in Quick Launch by specifying an alternate data source through a delegate control Feature. For information about delegate controls, see Delegate Control (Control Templatization).

The following example shows the default data source declaration in default.master, which specifies QuickLaunchDataSource as the ControlId value.

<SharePoint:DelegateControl runat="server"
  ControlId="QuickLaunchDataSource"
  Scope="Web">
  <asp:SiteMapDataSource
    SiteMapProvider="SPQuickLaunchProvider"
    ShowStartingNode="False"
    id="QuickLaunchSiteMap"
    runat="server"
  />
</SharePoint:DelegateControl>

You can create a Feature that overrides the default delegate control by adding a folder to the \TEMPLATE\FEATURES directory that specifies an alternate data source.

First create a Feature.xml file that specifies the strong-named assembly and class to use as the data source, and that references another XML file (in this example, called MyCustomNavigationSiteSettings.xml) that specifies the elements that form parts of the Feature.

<Feature  Id="541F5F57-C847-4e16-B59A-B31E90E6F9EA"
  Title="My Custom Left Navigation"
  Description="Enables custom navigation for the left navigation area."
  Version="12.0.0.0"
  Scope="Web"
  ReceiverAssembly="MyStrongAssemblyName, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
  ReceiverClass="MyNamespace.MyCustomNavigationHandler"
  xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="MyCustomNavigationSiteSettings.xml"/>
  </ElementManifests>
</Feature>

The following MyCustomNavigationSiteSettings.xml file redefines the site map provider to use as the QuickLaunchDataSource control, setting 50 as the Sequence attribute value, which specifies that the custom control be used instead for left navigation nodes.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control Id="QuickLaunchDataSource" Sequence="50" 
    ControlClass="System.Web.UI.WebControls.SiteMapDataSource" 
    ControlAssembly="System.Web, version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <Property Name="SiteMapProvider">AreasAndPagesSiteMapProvider</Property>
    <Property Name="EnableViewState">true</Property>
    <Property Name="StartFromCurrentNode">true</Property>
    <Property Name="StartingNodeOffset">0</Property>
    <Property Name="ShowStartingNode">false</Property>
    <Property Name="ID">qlSiteMap</Property>
  </Control>
  <HideCustomAction
    Id="QuickLaunch"
    HideActionId="QuickLaunch"
    GroupId="Customization"
    Location="Microsoft.SharePoint.SiteSettings" />
</Elements>

For more information about creating and implementing Features in Windows SharePoint Services, see Working with Features. See ASP.NET 2.0 QuickStart Tutorial for information about creating an assembly to serve as a custom data source provider.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Microsoft.SharePoint.Publishing ??      DMDJ ... Andrew Connell [MVP]   |   Edit   |   Show History

It does not appear the Microsoft.SharePoint.Publishing is a component of WSS 3.0. Is this documentation correct?

AC: Correct... it is a component of MOSS.

Tags What's this?: Add a tag
Flag as ContentBug
Control NOT of type IHierarchicalDataSource      Jaco Karsten   |   Edit   |   Show History

When I try to run this code I get an error message saying:

"The DataSourceID of 'QuickLaunchMenu' must be the ID of a control of type IHierarchicalDataSource. A control with ID 'QuickLaunchSiteMap' could not be found."

Stack Trace:

[HttpException (0x80004005): The DataSourceID of 'QuickLaunchMenu' must be the ID of a control of type IHierarchicalDataSource. A control with ID 'QuickLaunchSiteMap' could not be found.]
System.Web.UI.WebControls.HierarchicalDataBoundControl.GetDataSource() +1415249
System.Web.UI.WebControls.HierarchicalDataBoundControl.ConnectToHierarchicalDataSource() +158
System.Web.UI.WebControls.HierarchicalDataBoundControl.OnLoad(EventArgs e) +16
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

What am I missing?

Tags What's this?: Add a tag
Flag as ContentBug
Error in the example      jrathi ... Thomas Lee   |   Edit   |   Show History

There is an error in the code. The Control markup should look like this -

<Control Id="QuickLaunchDataSource" Sequence="50"
ControlClass="System.Web.UI.WebControls.SiteMapDataSource"
ControlAssembly="System.Web, version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Property Name="SiteMapProvider">AreasAndPagesSiteMapProvider</Property>
<Property Name="EnableViewState">true</Property>
<Property Name="StartFromCurrentNode">true</Property>
<Property Name="StartingNodeOffset">0</Property>
<Property Name="ShowStartingNode">false</Property>
<Property Name="ID">QuickLaunchSiteMap</Property>
</Control>

Flag as ContentBug
Create an assembly to server as a custom data source provider?      TACantrell ... MUstafa Fazlyi   |   Edit   |   Show History

Does anyone have a "how to" link for creating the custom data source provider in an assembly? I am not able to find this info. from the ASP.NET Quickstart tutorial link given above.

Or a workaround for the error message: The SiteMapProvider 'AreasAndPagesSiteMapProvider' cannot be found.

Thanks.

Tags What's this?: Add a tag
Flag as ContentBug
System.Web Version Ref. - Version not found & Question on behavior      czullu   |   Edit   |   Show History

I could not find the Version 2.0.3600.0 of System.Web even i have all the Frameworks on it. I have choosen the System.Web Version 2.0.0.0 instead. The problem i deal with extends to the sample, but i still like to ask.

I have two strange behaviors:

1. My Class Constructor derived from SPNavigationProvider gets call but the override method of GetChildNodes is never been called. I figured out that the Property currentNode is called an when i return a Custom node the GetChildNode is called after that - but then i loose the Menue-Entries from the underlying Provider. Is there something i'm missing?

2. If i'm in the Subsite and i click Fast after the refresh the Tab in the Top-Nav-Bar again, then sometimes i get the original Provider instead of mine - cloud that be caused by the Feature Stapling?

Thanks for Any Help.

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker