2

I am trying to make a left navigation bar to SharePoint 2010 with this teckniq=http://www.helpmeonsharepoint.com/2012/03/custom-sharepoint-top-menu-and.html

I Have got this Error massage:

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

Sorce Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack trace

[HttpException (0x80004005): The DataSourceID of 'V4QuickLaunchMenu' 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() +2335265 System.Web.UI.WebControls.HierarchicalDataBoundControl.ConnectToHierarchicalDataSource() +212 System.Web.UI.WebControls.HierarchicalDataBoundControl.OnLoad(EventArgs e) +28 System.Web.UI.Control.LoadRecursive() +66 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Control.LoadRecursive() +191 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

I have found that it can bee a lot of different reasont to why this hapend. I have tryed to change my XML file with out sucsess. I hope you will understand what I'm doing wrong.

I will post the parts of my code that i think is relevent Here is my code:

In web.config inside SiteMap-> providers I added this:

<add name="CustomNavigationProvider"
                                    type="BNS.Intranet.HR.CustomPortalNavigation, BNS.Intranet.HR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" />

cs-file

    namespace BNS.Intranet.HR
{
    public class CustomPortalNavigation : PortalSiteMapProvider
    {
        public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node)
        {
            PortalSiteMapNode pNode = node as PortalSiteMapNode;
            if (pNode != null)
            {
                if (pNode.Type == NodeTypes.Area)
                {
                    SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode);
                    PortalSiteMapNode childNode = new PortalSiteMapNode(pNode.WebNode, "1", NodeTypes.Area, "http://sp2010dev04/navi/",
                        "1", "1");

                    PortalSiteMapNode childNode1 = null;
                    for (int i = 0; i < 20; i++)
                    {
                        childNode1 = new PortalSiteMapNode(childNode.WebNode, "1.1" + i, NodeTypes.Area,
                                    "http://sp2010dev04/navi", "1.1", "1.1");
                    }

                    nodeColl.Add(childNode);
                    SiteMapNodeCollection test = new SiteMapNodeCollection();
                    if (childNode1 != null)
                    {
                        test.Add(childNode1);
                        childNode.ChildNodes = test;
                    }
                    return nodeColl;
                }
                else // Shouldn't it always return base.GetChildNodes?
                    return base.GetChildNodes(pNode);
            }
            else  // Only return new SiteMapNodeCollection when pNode is null?
                return new SiteMapNodeCollection();
        }

Elements.xml-file

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Control Id="QuickLaunchDataSource" Sequence="30"
             ControlClass="System.Web.UI.WebControls.SiteMapDataSource"
             ControlAssembly="System.Web, Version=2.0.3600.0, Culture=Neutral, PublicTokenKey=71e9bce111e9429">
        <Property Name="ID">QuickLaunchSiteMap</Property>
        <Property Name="SiteMapProvider">CustomSiteMapProvider</Property>
        <Property Name="EnableSecurityTrimming">false</Property>
        <Property Name="EnableViewState">true</Property>
        <Property Name="ShowStartingNode">false</Property>
        <Property Name="StartingNodeOffset">0</Property>
        <Property Name="StartFromCurrentNode">false</Property>
    </Control>
    <HideCustomAction Id="QuickLaunch"
                     HideActionId="QuickLaunch"
                     GroupId="Customization"
                     Location="Microsoft.SharePoint.SiteSettings" />
</Elements>

My delegate controls in the masterpage

<SharePoint:DelegateControl ID="DelegateControl5" runat="server" ControlId="QuickLaunchDataSource">
    <Template_Controls>
                    <asp:SiteMapDataSource SiteMapProvider="SPNavigationProvider" ShowStartingNode="False" id="QuickLaunchSiteMap" StartingNodeUrl="sid:1025" runat="server" />
                 </Template_Controls>
</SharePoint:DelegateControl>

Two new ones

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="DelegateControl8">
  <Template_Controls>
   <asp:SiteMapDataSource
     ShowStartingNode="False"
     SiteMapProvider="SPNavigationProvider"
     id="SiteMapDataSource1"
     runat="server"
     StartingNodeUrl="sid:1002"/>
  </Template_Controls>
 </SharePoint:DelegateControl>

<SharePoint:DelegateControl ID="DelegateControl9" runat="server" ControlId="QuickLaunchDataSource">
<Template_Controls>
  <asp:SiteMapDataSource SiteMapProvider="SPNavigationProvider"
ShowStartingNode="False"
id="SiteMapDataSource2"
StartingNodeUrl="sid:1025"
runat="server" />
 </Template_Controls>
</SharePoint:DelegateControl>
  • Can You post your SharePoint Delegate Control Code – SharePointMan Feb 25 '14 at 10:10
  • Hello Ashish, I have added my delegate controle to the question now. – Malin Nilsson Feb 25 '14 at 10:18
  • There are 2 Delegate controls. – SharePointMan Feb 25 '14 at 10:39
  • There are? Then where should I finde the one you want to see? – Malin Nilsson Feb 25 '14 at 10:40
  • 1
    Yes, write it as an answer then I can wote you up. – Malin Nilsson Feb 25 '14 at 10:58
3

Try adding Both Delegate controls and it should resolve your problem.

  • 1
    I didn't understand, what do you mean by both delegate controls ? – Tito Jul 6 '16 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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