Create Custom Navigation for SharePoint:AspMenu

Third Party HTML/JS

Wednesday, May 25, 2011

As you are probably aware, there are many different ways to create a navigation in Sharepoint 2010. This blog will focus on ONE specific way that is both easy and powerful. I will show you how to create a left navigation without overwhelming readers with loads of information they don't need and can probably figure out on their own.

1) Create the menu hierarchy in site settings.
Go to Site Actions > Site Settings > Navigation
Create all the menu entries and sub-entries that you need for your menu.

2) In the master page, there should be a node for the SharePoint:AspMenu. It should look something like the following:

It is not easy to apply custom styling to this and even the styling capabilities it has is limited.

3) In order to apply custom styling, we will use asp:Repeater to dynamically generate the desired html/css code. The following code can replace only the SharePoint:AspMenu and should allow you create whatever html/css code you need for styling. This is a two level navigation where each main header can have multiple children. This can be specified in the Navigation site settings.

HeaderTemplate - Anything between these tags will be outputted ONCE before the repeater begins looping for the itemtemplate

SeparatorTemplate -Anything between these tags will be outputted between each item template

ItemTemplate - Anything between these tags will be applied for EACH element in the source data, in this case out navigation entries. Further more, you can use another repeater inside this to output the sub-entries as shown in the code above.

FooterTemplate - Anything between these tags will be outputted ONCE after the item templates have outputted.

I hope this tutorial have been helpful in creating a custom styled navigation for Sharepoint 2010.