Home > SharePoint Development > Tip for custom Quick Launch Navigation

Tip for custom Quick Launch Navigation

When creating custom headings within the Quick Launch navigation, whether using the object model or a site definition, always ensure that there is a target URL for each navigation element otherwise the custom heading will be displayed as highlighted.

By way of example, the Microsoft SharePoint Guidance uses the following code to create a custom heading called ‘Dashboards’ in the Quick Launch navigation:

groupNode = new SPNavigationNode("Dashboards", String.Empty);

Note that there is no target for this navigation heading, instead String.Empty is being passed in. This results in the ‘Dashboards’ being highlighted within Quick Launch regardless of the actual mouse pointer focus:

Highlighted heading within Quick Launch

Sometimes, as in the case above, there isn’t a obvious target for the heading. However it would still be better to supply a URL rather than leave the target blank as thus avoid the heading being permanently highlighted. To do this, use some code similar to the following:

groupNode = new SPNavigationNode("Dashboards", web.Url, true);

Note the use of the third parameter that specifies that the link is an external node, this is required to make use of the SPWeb.Url property which returns the absolute URL of the web site.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: