Update Quick Launch

NavigationNodeCollection quickluanch = null;
quickluanch = web.Navigation.QuickLaunch;
context.Load(quickluanch);
context.ExecuteQuery();
for (int i = quickluanch.Count - 1; i >= 0; i--)
{
    quickluanch[i].DeleteObject();
}
NavigationNodeCreationInformation createQuick = new NavigationNodeCreationInformation();
//Head
createQuick.Title = "Home";
createQuick.AsLastNode = true;
createQuick.Url = "SitePages/Home.aspx";
quickluanch.Add(createQuick);

NavigationNode nodeLeader = quickluanch.Where(q => q.Title == "Home").SingleOrDefault();
//Link
createQuick.Title = "Link";
createQuick.AsLastNode = true;
createQuick.Url = "Lists/Link/AllItems.aspx";
nodeLeader.Children.Add(createQuick);
context.ExecuteQuery();

猜你喜欢

转载自www.cnblogs.com/jackhu88/p/9208743.html