Monday, September 10, 2007 4:29 PM Jan Tielens

Adding Breadcrumb Navigation for SharePoint Application Pages

UPDATE: Also read my follow-up post: http://weblogs.asp.net/jan/archive/2008/04/16/adding-breadcrumb-navigation-to-sharepoint-application-pages-the-easy-way.aspx

Application Pages in SharePoint 2007 are a great way to extend SharePoint’s default user interface for your custom SharePoint solutions. An application page is deployed once per Web server and it’s not possible to customize these pages per site (like the normal Site Pages). A good example of an Application Page is the default Site Settings page: every site has one, and it’s not customizable on a per site basis (although the contents can be different for sites). A very basic application page could look like:

<%@ Page MasterPageFile="~/_layouts/application.master"
    Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase"   
    Language="C#"%>
<asp:Content
    contentplaceholderid="PlaceHolderPageTitle" runat="server">
Jan's Page
</asp:Content>

<asp:Content
    contentplaceholderid="PlaceHolderPageTitleInTitleArea"
    runat="server">
Jan's Page   
</asp:Content>

<asp:Content
    contentplaceholderid="PlaceHolderMain"
    runat="server">
Jan's fantastic Application Page content goes here!
</asp:Content>

When this ASPX page is saved in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS folder, it can be accessed from any site by making use of the following URL: http://siteurl/optionalsubsite/_layouts/pagename.aspx.

 

(More information about creating your own Application Pages can be found in Ted Pattison's excellent Visual How-To) As you can see, this page resembles the Site Settings page (or any other default Application Page) quite well. But there is one important thing missing: the breadcrumbs above the page title! Check for example the default Site Settings page:

You can’t fix this by adding a breadcrumb control (aka SiteMapPath control) to the Application Page, actually there is already a breadcrumb on the page (defined in the default master page), the issue is that the new Application page is simply not known by the navigation infrastructure. Luckily this is quite easy to solve: SharePoint uses the ASP.NET 2.0 navigation functionality, so you just have to update the site’s sitemap. This is an XML file containing the navigation hierarchy and is located in C:\Inetpub\wwwroot\wss\VirtualDirectories\wss.u2ucourse.com\_app_bin\layouts.sitemap. If you want that your Application Page behaves as a sub page of the Site Settings page (a common scenario for Application Pages), look for the siteMapNode of the settings page:

<siteMapNode title="$Resources:wss,settings_pagetitle" url="/_layouts/settings.aspx">

And add your own siteMapNode as a child element:

<siteMapNode title="Jan's Page" url="/_layouts/jan.aspx"/>

Et voila, the custom Application Page’s breadcrumb control will automatically display the correct breadcrumb links. Of course modifying the layouts.sitemap file manually is not very nice since a SharePoint environment could have more than one web application (potentially on different servers), so you’d have to edit a couple of files. But of course you can automate this as well, I’ll go into the details in a follow-up post.

UPDATE: Also read my follow-up post: http://weblogs.asp.net/jan/archive/2008/04/16/adding-breadcrumb-navigation-to-sharepoint-application-pages-the-easy-way.aspx 

Comments

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Monday, September 10, 2007 11:26 AM by Kanwal

Jan... thats exactly what I was looking for.  Thanks mate!

# SharePoint 2007 link love 09-13-2007 at Virtual Generations

Thursday, September 13, 2007 5:25 PM by SharePoint 2007 link love 09-13-2007 at Virtual Generations

Pingback from  SharePoint 2007 link love 09-13-2007 at  Virtual Generations

# SharePoint Kaffeetasse 21

Monday, September 17, 2007 5:35 AM by SharePoint, SharePoint and stuff

Schritt-für-Schritt zur eigenen Web Content Management Site und diese dann mit optimierter Performance

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Wednesday, October 03, 2007 3:36 PM by corni

What if you dont have breadcrumbs showing...A custom template that for some reason doesn't show any breadcrumbs.  I would like to know where to check for them....

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Friday, October 05, 2007 11:55 PM by gmail001

HI

a great atricle. but can u give better approach how to do the dode behind.  

is there a better approach than this

compile the site into a single dll , deployt he dll in thebin and then copy the aspx to the _layouts folder and then modify the webconfig to reister the safe controlls r asemblies.

what is the best approach ,How do we add the code behing and file or a different class to register to add functionality tog the content pages.

in vss 2005 we can compile int oindividual  seperate asemblies  with stong name . and deploy them seperately or  into one assembly into gac.  which one do u think the best way.

thanks

gmail001

thanks

gmail001

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Friday, October 19, 2007 2:21 PM by Parthi

Good artcile, But this not the right way of doing it, in the sense that you are editing files in 12 Hive which is owned by Microsoft.

This will work for testing purposes, but move same thing to a shared production environment will be a big challenge ...

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Thursday, November 15, 2007 2:06 AM by NithyaLavanyaDass

I am working on WSS 3.0, breadcrumbs are missing in document libraries after the site upgradation from WSS 2.0. Could you please help me out in finding the solution?

Regards

Nithya

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Friday, November 16, 2007 5:38 AM by Manoj

Hi Jan,

I think your article is fantastic. And it really saved my day. I was planning to do the same with the help of custom feature and creating my custom navigation.

Eagerly awaiting your post on automated deployment of your approach in a farm/production scenario

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Tuesday, November 27, 2007 6:29 AM by Dipak Fatania

how can i add breadcrumb to site pages or custom pages? I am adding custom pages by addign the new link in top menu bar using feature. I will be very helpful to me if anybody can answer this.Thanks in advance.

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Thursday, November 29, 2007 4:46 PM by talamar

How about breadcrumb navigation for sub-sites?  How would one accomplish that task?

# Applications Pages in SharePoint - Getting Started

Wednesday, December 12, 2007 1:27 AM by Mattias talks about SharePoint, BizTalk, .NET, TFS, etc.

It's been a while since I created an actual page in SharePoint that provided some actual functionality,

# Applications Pages in SharePoint - Getting Started

Wednesday, December 12, 2007 1:34 AM by Noticias externas

It&#39;s been a while since I created an actual page in SharePoint that provided some actual functionality

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Thursday, December 20, 2007 5:52 PM by Brian Staton

The WSS SDK hints at a better way of doing this (see the article titled Central Administration Pages).  With a lot of experimentation, I finally figured out how to get it to work.

Create an xml file in the TEMPLATE\LAYOUTS folder that matches the pattern "layouts.sitemap.*.xml" e.g. layouts.sitemap.mypages.xml.  

The file should contain nodes like:

<siteMap>

   <siteMapNode title="My Custom Page" url="/_layouts/mypages/Page.aspx" parentUrl="/_layouts/settings.aspx" />

</siteMap>

SharePoint will merge your sitemap with the default sitemap and re-create the _app_bin/layouts.sitemap file when you either execute "stsadm -o copyappbincontent" or call the API method SPWebService.ApplyApplicationContentToLocalServer.

That way you can keep your sitemap separate from SharePoint's and easily include it in a Feature or Solution.

# re: Adding Breadcrumb Navigation for SharePoint Application Pages

Thursday, December 27, 2007 10:17 AM by Tania Markova

Thanks a lot to Brian Staton for finding better way to merge custom sitemaps with SharePoint ones. Your answer helped me much.

I have a question concerning adding breadcrumbs to files residing SharePoint ADMIN folder. I add "admin.sitemap.*.xml" file to TEMPLATE\ADMIN folder. Then I call SPWebService.AdministrationService.ApplyApplicationContentToLocalServer() to merge custom sitemap with SharePoint one. This works fine. But when I open custom page that is placed in ADMIN folder breadcrumbs are not shown. What can the reason be?

Also I have found a couple of fine articles about adding breadcrumb navigation for SharePoint custom pages that helped me a lot:

Configuring the breadcrumb for pages in _layouts:

blog.thekid.me.uk/.../configuring-the-breadcrumb-for-pages-in-layouts.aspx

Creating Dynamic Breadcrumbs in SharePoint ASPX Pages:

www.mikhaildikov.com/.../creating-dynamic-breadcrumbs-in.html

Thank you.

# Adding Breadcrumb Navigation to SharePoint Application Pages, the Easy Way

Wednesday, April 16, 2008 12:01 PM by Jan Tielens' Bloggings

A while ago I posted an article about how you could build custom Application Pages for SharePoint that

# Creating an Application Page in SharePoint

Thursday, June 26, 2008 4:17 PM by Creating an Application Page in SharePoint

Pingback from  Creating an Application Page in SharePoint

# SharePoint Fun &raquo; Blog Archive &raquo; How to Add Telerik Controls to Your Custom SharePoint Application Pages

Pingback from  SharePoint Fun  &raquo; Blog Archive   &raquo; How to Add Telerik Controls to Your Custom SharePoint Application Pages