More Efficent Sitefinity Breadcrumb

November 25, 2012
The Sitefinity breadcrumb widget works well, however it's got a couple things you might want to fix...

1) It sends down a RadSiteMap stylesheet...the whole thing I'm estimating about 4k, probably a bit less with Gzip...regardless, it's larger than you need.  Most designers call for their own style anyway, so just wipe and start from scratch.

2) This is a bug with most simpleview based controls.  Without the Render function modified they're wrapped in empty elements.  In this case an empty div wraps the entire control (no class or anything to get a handle on it).

So just create a new class somewhere in your project, paste this in (adjust the namespace), then in settings use it over the base breadcrumb.

It'll be a MARGINAL amount of work to style it, but saves bytes :)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using Telerik.Sitefinity.Web.UI;
using Telerik.Web.UI;
namespace MyProjectNameSpace
    public class CustomBreadcrumb : global::Telerik.Sitefinity.Web.UI.NavigationControls.Breadcrumb.Breadcrumb
        protected override void InitializeControls(GenericContainer container)
            this.SiteMapBreadcrumb.DataBound += SiteMapBreadcrumb_DataBound;
        void SiteMapBreadcrumb_DataBound(object sender, EventArgs e)
            //Root node, allow for images
            RadSiteMap sitemap = (RadSiteMap)sender;
            if (sitemap.Nodes.Count > 0)
                sitemap.Nodes[0].Text = String.Format("<span>{0}</span>", sitemap.Nodes[0].Text);
                sitemap.Nodes[0].CssClass = "rootnode";
                if(sitemap.Nodes.Count > 1){
                    sitemap.Nodes.Last().CssClass = "lastnode";
        protected override void CreateChildControls()
            this.ClientIDMode = System.Web.UI.ClientIDMode.Static; //Who has more than 1 of these, why make the ID obnoxious
            this.SiteMapBreadcrumb.EnableEmbeddedBaseStylesheet = false;
            this.SiteMapBreadcrumb.EnableEmbeddedSkins = false;
            ((SitefinityLabel)this.BreadcrumbLabel).HideIfNoTextMode = HideIfNoTextMode.Server; //If it's not set, dont render it
        /// <summary>
        /// Breadcrumb renders with an emtpy div around it, this removes it
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)

@Telerik, please feel free to make these core :)


Image Description

Steve McNiven-Scott

Best\Only Blogger on this site. Therefore defacto blogger of the year Award Winner.