Custom Cross site collection Navigation using user control


Sometimes the out of box navigation does not provides us the type of navigation wants on the whole application. To make such custom navigation which is consistent throughout many site collection it is batter to create a custom user control and simply register it in to the master page. Applying the same master page on every site collection will do the job.

Follow below steps to create the user control:

1) Right click on the project and the click on Add New Item.

2)Then add a User Control. Name it as per the convention.

3)Under the ascx file create any type of control you wana use, I prefer asp menu:

<div >
<asp:Menu ID=”MyTopMenu” Orientation=”Horizontal” runat=”server”>
<StaticMenuItemStyle CssClass=”topNavStaticMenuItem”/>
<StaticSelectedStyle CssClass=”topNavSelectedStaticMenuItem”></StaticSelectedStyle>

4) Now next step is to populate the menu with the tabs:

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
var homeLinkTitle = “Home”;
var homeLinkUrl = “;;

ApoteoseTopMenu.Items.Add(new MenuItem(homeLinkTitle) { NavigateUrl = homeLinkUrl, Selected = true });
ApoteoseTopMenu.Items.Add(new MenuItem(“Google”) { NavigateUrl = “”, Selected = false });

5) Now next step is to add this control to the master page:

<%@ Register TagPrefix=”MyTopNavControl” TagName=”CurrentPageControl” src=”~/_ControlTemplates/MyTopNavControl.ascx” %>

also add below line at the required placeholder.

<MyTopNavControl:CurrentPageControl ID=”topNav” runat=”server”></MyTopNavControl:CurrentPageControl>

6) Build and deploy the application and enjoy the consistent navigation 🙂

Happy Sharepointing….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s