Wednesday, August 22, 2012

Add & Delete Top& Left Navigation Links using Object model in Sharepoint

  Adding Left Navigation Link
SPSite quickLaunchSite = new SPSite("http://sreenu:5555/Test");
         SPWeb quickLaunchWeb = quickLaunchSite.OpenWeb();
SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.QuickLaunch;
        //add left navigation internal site
  SPNavigationNode internalMenuItem = new SPNavigationNode("Links", "/uday/SitePages/Home.aspx", false);
                 //add left navigation external site
      quickLaunchNodes.AddAsFirst(internalMenuItem);
  SPNavigationNode externalMenuItem = new SPNavigationNode("SharePoint Blog", "http://sreenuknowledge.blogspot.in/", true);
 quickLaunchNodes.AddAsFirst(externalMenuItem);
            quickLaunchNodes.Navigation.QuickLaunch[0].Delete();  
          quickLaunchWeb.Update();
            Console.WriteLine("Successfulled added");
            Console.Read();


Deleting Left Navigation Links
quickLaunchNodes.Navigation.QuickLaunch[0].Delete();  

Adding Top Navigation Link
  SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.TopNavigationBar;

Deleting Top Navigation Links
 quickLaunchNodes1.Navigation.TopNavigationBar[0].Delete();


No comments:

Post a Comment