1

I want to get title/Url from of site navigation in sharepoint programmatically. how to do this ?

I have only Current.Site.Web.Url, but not have a child to get site with index..

using (SPSite oSite = new SPSite(SPContext.Current.Site.Url))
{
    using (SPWeb oWeb = oSite.OpenWeb())
    {

    }
}
1

You can use the property Navigation.QuickLaunch to get all the left navigation items

SPNavigationNodeCollection nodeCollection = oWeb.Navigation.QuickLaunch;

Then iterate through it to find Title and Url

using (SPSite site = new SPSite("http://localhost"))
{
       using (SPWeb web = site.OpenWeb("/"))
       {
                foreach (SPNavigationNode heading in web.Navigation.QuickLaunch)
                {
                    Console.WriteLine("\n{0} [{1}]", heading.Title, heading.Url);

                    foreach (SPNavigationNode child in heading.Children)
                        Console.WriteLine(" {0} [{1}]", child.Title, child.Url);
                }
       }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.