0

I want to remove a navigationnode (Not disable QuickLaunch) from Navigation sharepoint online 2013

ClientContext context = ClaimClientContext.GetAuthenticatedContext(targetURL, 600, 600);
                NavigationNodeCollection collNavNode = context.Web.Navigation.QuickLaunch;
                context.Load(collNavNode);
                foreach (SP.NavigationNode node in collNavNode)
                {
                    node.DeleteObject();
                }

                context.ExecuteQuery();

It's not working.

Hoang Tung
  • 23
  • 1
  • 6

1 Answers1

1

How to delete all nodes from QuickLaunch using SharePoint CSOM:

public static void ClearQuickLaunch(string url, ICredentials credentials)
{
    using (var context = new ClientContext(url))
    {
        context.Credentials = credentials;

        NavigationNodeCollection qlNodes = context.Web.Navigation.QuickLaunch;
        context.Load(qlNodes);
        context.ExecuteQuery();

        qlNodes.ToList().ForEach(node => node.DeleteObject());
        context.ExecuteQuery();
    }
}
Vadim Gremyachev
  • 57,952
  • 20
  • 129
  • 193