Tuesday, November 18, 2008
« SharePoint People Picker and Changing Au... | Main | Browser cookies: the path is case sensit... »

I was building a breadcrumb trail for a site I was working on, and using the SiteMapPath control to render the breadcrumb. I wanted to hide the root node from the breadcrumb, but as the SiteMapControl gets its data directly from a SiteMapProvider rather than via a SiteMapDataSource, we cant use the SiteMapDataSource.ShowStartingNode property to hide the root node. I used this workaround:

Handle the SiteMapPath's ItemCreated event, where you can hide the root node:

    //override the Page's OnInit
    protected override void OnInit(EventArgs e)

        Breadcrumb.ItemCreated += new SiteMapNodeItemEventHandler(Breadcrumb_ItemCreated);

    void Breadcrumb_ItemCreated(object sender, SiteMapNodeItemEventArgs e)

        //hide the root node, and it's following path separator
        if (e.Item.ItemIndex == 0 
            | (e.Item.ItemIndex ==1 && e.Item.ItemType ==SiteMapNodeItemType.PathSeparator))
            e.Item.Visible = false;
Tuesday, November 18, 2008 12:56:57 PM (GMT Standard Time, UTC+00:00)  #      Comments [0]  |  Trackback
Comments are closed.