hi,
i have to create a node to topnavigationbar. each node will have some pages
node--
page1
page2
1) i am able to create the node and adding pages but on the top navigation bar when i click the node the list is not collapsing ...
2) for pages i add i need to pass url
the url i an passilng is
"/pages/pageviewer.aspx?RC=" +rc+"&RD="+rd;
but when i am check in the navigation under site settings --
the url it is taking is "/pages/pageviewer.aspx"
can any one provide links or solution
Loading
Hemant KumarPosted Oct 10, 2011, 7:40 AM
using System; using Microsoft.SharePoint; using Microsoft.SharePoint.Navigation; namespace ConsoleApp { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://localhost")) using (SPWeb web = site.OpenWeb()) { if (web.Navigation.UseShared) return; // Get the top link bar. SPNavigationNodeCollection topnav = web.Navigation.TopNavigationBar; // Iterate over the collection of subsites. foreach (SPWeb subweb in web.Webs) { // Check for an existing link. SPNavigationNode node = web.Navigation.GetNodeByUrl(subweb.ServerRelativeUrl); if (node == null || node.ParentId != 1002) { // No link, so add one. // Truncate a long title. string linkTitle = subweb.Title; if (linkTitle.Length > 15) linkTitle = linkTitle.Substring(0, 12) + "..."; // Create the link. node = new SPNavigationNode(linkTitle, subweb.ServerRelativeUrl); // Add it to the top link bar. node = topnav.AddAsLast(node); } subweb.Dispose(); } } Console.Write("\nPress ENTER to continue...."); Console.ReadLine(); } } }
refer this link
http://snahta.blogspot.com/2009/04/adding-top-navigation-bar.html