Monday, June 06, 2011

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
Share:

0 comments:

About Me

My photo
Based in Bangalore, INDIA, Amit is a MCC. He has an MCA from the U.P.T.U., INDIA and holds Microsoft certifications including SharePoint 2007/2010/2013. He is an contributor to MSDN and http://amitkumarmca04.blogspot.com/. Amit have experience in SharePoint,ASP.Net with C#, Classic ASP, VB,Macros,HTML,JavaScript,JSON,BootStrap and AngularJS.

Followers

Labels