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 currently porting an application from SharePoint 2007 to 2010. As a single page can be invoked in different contexts, we rely on a code based SiteMapResolveEventHandler to dynamically populate the breadcrumb.

This all works great in SharePoint 2007, but for some reason in SharePoint 2010 it doesn't hit the 'SPXmlContentMapProvider' event handler even though this provider is available in the list of SiteMap.Providers.

If I hook up the event to a different provider, e.g. the CombinedNavSiteMapProvider then it does trigger the event handler, but this provider does not contain the nodes I am interested in.

The following code is being used (and works fine in SP2007)

In the application page's OnLoad

SiteMap.Providers["SPXmlContentMapProvider"].SiteMapResolve += new SiteMapResolveEventHandler(provider_SiteMapResolve);

which calls the following method (simplified version)

public SiteMapNode provider_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
{
    e.Provider.EnableLocalization = false;

    // ** First request uses the current user's account to load sitemap file, so elevate.
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        SiteMapNode listNode = e.Provider.RootNode.ChildNodes[0].Clone();
        listNode.Url = "http://some url";
        listNode.Title = "Some title";
        listNode.ChildNodes = new SiteMapNodeCollection();

        SiteMapNode pageTitleNode = new SiteMapNode(e.Provider, Guid.NewGuid().ToString());
        pageTitleNode.Title = "Some sub title";
        listNode.ChildNodes.Add(pageTitleNode);
        pageTitleNode.ParentNode = listNode;
    });

    return pageTitleNode;
}

I have checked that the event handler is never invoked by adding trace logging to the method as well as breakpoints.

share|improve this question

2 Answers 2

In SharePoint 2010 Application pages need to override the PlaceHolderTitleBreadcrumb section from v4.master in order to specify that the SPXMLContentMapProvider be used. This will allow the breadcrumb control to work. Additionally the title area needs to be adjusted to show a "breadcrumb like" navigation.

I've posted all of the code changes required on my blog: http://blogs.visigo.com/chriscoulson/adding-breadcrumb-navigation-to-sharepoint-2010-application-pages/

share|improve this answer

Have u tried using another Provider? I think SP2010 uses SPSiteMapProvider or SPContentMapProvider...

share|improve this answer
    
I looked at all providers registered in the system and tried them all without luck. –  Muhimbi Dec 8 '10 at 8:30

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.