Accessing SharePoint Quick Launch menu (SPNavigation.QuickLaunch) using C#:

Accessing SharePoint Quick Launch menu (SPNavigation.QuickLaunch) using C#:
With the help of SPNavigation, we will be able to access the Quick Launch menu of SharePoint site. Sometimes we need to show/hide Quick Launch menu item, so with the help of SPNavigation. QuickLaunch, we can loop through Quick Launch menu item.
In this example we will access Quick Launch menu:


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using System.Web;
using Microsoft.SharePoint.Navigation;


namespace GetQuickLaunch
{
class Program
{
static void Main(string[] args)
{

using (SPSite site = new SPSite("http://amitkumarmca04.blogspot.com/"))
{
using (SPWeb web = site.OpenWeb())
{
SPNavigationNodeCollection qlNodes = web.Navigation.QuickLaunch;
foreach (SPNavigationNode node in qlNodes)
{
Console.WriteLine(node.Title + "--" + node.Url);
}
}
}
}
}
}




Reference: MSDN

Post a Comment

Previous Post Next Post