Use below method to get the Quick Launch information from the current web.
public static void QuickLaunch()
{
using (SPSite site = new SPSite(strSiteCollectionURl))
{
using (SPWeb web = site.OpenWeb()) //Can user SPContext.Current.Web
{
SPNavigationNodeCollection quickLaunchNodes = web.Navigation.QuickLaunch;
//Parent
foreach (SPNavigationNode node in quickLaunchNodes)
{
string strParentTitle = node.Title;
string strParentURL = node.Url.ToString();
Console.WriteLine("Parent : "+strParentTitle + " : " + strParentURL);
//Children
SPNavigationNodeCollection children = node.Children;
foreach (SPNavigationNode child in children)
{
string strTitle =child.Title;
string strURL = child.Url.ToString();
Console.WriteLine("Child : " + strTitle + " : " + strURL);
}
}
Console.ReadKey();
}
}
}
No comments:
Post a Comment