SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am implementing some custom navigation providers for SharePoint 2010, and have successfully overridden the data source for the Top Navigation and Quick Launch providers using the delegate provided for in v4.master.

I'm now trying to do the same for the TreeView navigation, however every time I activate my feature it clears the TreeView, suggesting its doing the override, but not then populating it.

I'm not getting any errors of exceptions I can see.

My custom navigation provider is (hard-coded items for brevity):

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Publishing.Navigation;
using System.Web;

namespace AdamM.SharePoint.Navigation
    class NavigationSiteMapProvider : PortalSiteMapProvider
        public override SiteMapNodeCollection GetChildNodes( SiteMapNode node )
            PortalSiteMapNode pNode = node as PortalSiteMapNode;

            if (pNode != null)
                if (pNode.Type == NodeTypes.Area && pNode.WebId == SPContext.Current.Site.RootWeb.ID)
                    SiteMapNodeCollection nodeColl = base.GetChildNodes( pNode );

                    SiteMapNode childNode = new SiteMapNode(this, "item1", "/sites/sandpit/", "Manage Features");
                    SiteMapNode childNode1 = new SiteMapNode(this, "item2", "/sites/sandpit/_layouts/settings.aspx", "Settings");
                    SiteMapNode childNode2 = new SiteMapNode(this, "item3", "/sites/sandpit/_layouts/ManageFeatures.aspx", "Manage Features 2");

                    childNode1.ChildNodes = new SiteMapNodeCollection(childNode2);

                    nodeColl.Add(childNode );

                    return nodeColl;

                return base.GetChildNodes(pNode);

            return new SiteMapNodeCollection();

And for the Quick Launch, for example, my Feature elements.xml is:

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="">
    <Control Sequence="30" Id="QuickLaunchDataSource" ControlClass="System.Web.UI.WebControls.SiteMapDataSource" ControlAssembly="System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Property Name="ID">QuickLaunchSiteMap</Property>
        <Property Name="SiteMapProvider">NavigationSiteMapProvider</Property>
        <Property Name="EnableViewState">false</Property>
        <Property Name="ShowStartingNode">true</Property>

For the TreeView my elements.xml is:

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="">
    <Control Sequence="1" Id="TreeViewAndDataSource" ControlClass="System.Web.UI.WebControls.SiteMapDataSource" ControlAssembly="System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Property Name="ID">TreeViewDataSource</Property>
        <Property Name="RootContextObject">NavigationSiteMapProvider</Property>

Can anyone please advise where I'm going wrong. This is the first thing I've written in SharePoint and this last bit has me baffled.


Adam M.

share|improve this question

Did you ever figure this out? I'm not sure, because I'm new to this, but it looks like in the case of the Quick Launch the delegate control is just the datasource, whereas with the TreeView it is the tree view and the data source.

share|improve this answer
That is correct, after staring at it for so long I was failing to see the woods for the trees it dawned on me exactly what you've said - they treeview and datasource where combined as a single delegatable unit unlike the quick launch where they're separate. That being the case I simply created my own User Control to override the delegate and included a treeview with my functionality in that. – Adam M. Mar 9 '13 at 15:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.