SharePoint uses SiteMapPath to define the breadcrum. If you notice SieMapPath doesn’t display the page which you’re currently on – meaning if you have a site with few pages on it – your breadcrumb will display the site but not the page. The good news is that you can extend the SiteMapPath to support display of the page.
In this case you’re new breadcrumb control class that will inherit from SiteMapPath will look like this:
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public partial class ExtendedBreadcrumb : SiteMapPath
{
protected override void InitializeItem(SiteMapNodeItem item)
{
if (item.ItemType == SiteMapNodeItemType.Current)
{
int itemId = SPContext.Current.ListItem.ID;
Guid webId = SPContext.Current.Web.ID;
Guid siteId = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site = new SPSite(siteId))
{
using (SPWeb web = site.OpenWeb(webId))
{
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
SPListItem page = publishingWeb.PagesList.GetItemById(itemId);
Literal leaf = new Literal();
if (site.RootWeb==web)
{
leaf.Text = string.Format("<span><a class='cp-RootNode' href={0}>{1}</a></span>
<span class='cp-separator'>{2}</span>",
web.Url, web.Title,this.PathSeparator);
}
if (page != null && !page.Title.Equals(item.SiteMapNode.Title))
{
leaf.Text += page.Title;
}
else
{
leaf.Text = item.SiteMapNode.Title;
}
item.Controls.Add(leaf);
}
}
});
}
else
{
base.InitializeItem(item);
}
}
}
Now you would be able to define your breadcrumb in your page something like this:
<asp:SiteMapPath CssClass="cp-Breadcrumb" SiteMapProvider="CurrentNavSiteMapProviderNoEncode" id="ContentMap" SkipLinkText="" RootNodeStyle-CssClass="cp-RootNode" PathSeparatorStyle-CssClass="cp-separator" PathSeparator="   " NodeStyle-CssClass="ms-sitemapdirectional" CurrentNodeStyle-CssClass="selected" RenderCurrentNodeAsLink="true" runat="server"/>
Good Luck!