Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 );
                    nodeColl.Add(childNode1);

                    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="http://schemas.microsoft.com/sharepoint/">
    <Control Sequence="30" Id="QuickLaunchDataSource" ControlClass="System.Web.UI.WebControls.SiteMapDataSource" ControlAssembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Property Name="ID">QuickLaunchSiteMap</Property>
        <Property Name="SiteMapProvider">NavigationSiteMapProvider</Property>
        <Property Name="EnableViewState">false</Property>
        <Property Name="ShowStartingNode">true</Property>
    </Control>
</Elements>

For the TreeView my elements.xml is:

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

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

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.

Thanks,

Adam M.

share|improve this question

1 Answer 1

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

 
discard

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.