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();

 

posted @ 2018-06-21 14:06  JackHu88  阅读(129)  评论(0)    收藏  举报