public override void AddNavigationNode(string title, string url, NavigationNodeLocation location) { NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation(); newNavNode.Title = title; newNavNode.Url = url; NavigationNodeCollection navNodeColl = null; switch (location) { case NavigationNodeLocation.TopNavigationBar: navNodeColl = _web.Navigation.TopNavigationBar; break; case NavigationNodeLocation.QuickLaunchLists: navNodeColl = _web.Navigation.QuickLaunch; break; default: throw new ArgumentOutOfRangeException(nameof(location), location, null); } try { navNodeColl.Add(newNavNode); _context.ExecuteQuery(); } catch (Exception) { //ignore, already exists } }
public override void AddNavigationNode(string title, string url, NavigationNodeLocation location) { SPNavigationNodeCollection topnav = null; SPNavigationNode node = new SPNavigationNode(title, url); if (_spWeb.Navigation.GetNodeByUrl(node.Url) != null) { return; } switch (location) { case NavigationNodeLocation.TopNavigationBar: topnav = _spWeb.Navigation.TopNavigationBar; topnav.AddAsLast(node); break; case NavigationNodeLocation.QuickLaunchLists: _spWeb.Navigation.AddToQuickLaunch(node, SPQuickLaunchHeading.Lists); break; default: throw new ArgumentOutOfRangeException(nameof(location), location, null); } }
public override void AddNavigationNode(string title, string url, NavigationNodeLocation location) { NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation(); newNavNode.Title = title; newNavNode.Url = url; NavigationNodeCollection navNodeColl = null; switch (location) { case NavigationNodeLocation.TopNavigationBar: navNodeColl = _web.Navigation.TopNavigationBar; break; case NavigationNodeLocation.QuickLaunchLists: navNodeColl = _web.Navigation.QuickLaunch; break; default: throw new ArgumentOutOfRangeException(nameof(location), location, null); } try { navNodeColl.Add(newNavNode); _context.ExecuteQuery(); } catch (Exception) { //ignore, vec postoji } }
public abstract void AddNavigationNode(string title, string url, NavigationNodeLocation location);