How to add new SPNavigationNode to Quick Link as type Link and not Heading

In SharePoint 2010, if you add a new SPNavigationNode as a child to a Heading link, then the type of the new link will automatically be Link:

If you however add it as a root level node, then the type will be Heading:

Use the following code to add a root level node as type Link:

using (var site = new SPSite("http://myServer"))
{
	using (var web = site.OpenWeb())
	{
		var newNode = new SPNavigationNode("Root Level Link", "http://www.ms.com", true);
		newNode = web.Navigation.QuickLaunch.AddAsFirst(newNode);
		newNode.Properties.Add("NodeType", "AuthoredLinkPlain");
		newNode.Update();
	}
}

newNode.Properties.Add(“NodeType”, “AuthoredLinkPlain”) is the magic line that makes it works.

Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in Branding, SharePoint 2010. Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s