从顶级网站进入子网站的列表以及文档库一般需要先进入子网站,然后再从子网站进入列表以及文档库。在顶级网站的顶部导航栏用 SPNavigationNodeCollection  对象添加下拉菜单以便快速进入子网站的列表以及文档库等。以下是用一个控制台程序在顶部导航栏的第二个节点分别添加 Excel 文档、word 文档、Project 文档,添加列表也是同样的方法。在Debug之前需要添加 Microsoft.sharepoint.dll 这个引用。

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 using Microsoft.SharePoint;
 5 using Microsoft.SharePoint.Navigation;
 6 
 7 namespace AddNavigationNode
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             SPSite mySite = new SPSite("http://server:1000");
14             SPWeb newSite = mySite.AllWebs[""];
15             SPNavigationNodeCollection TopNavigation = newSite.Navigation.TopNavigationBar;
16 
17             SPNavigationNode MenuItem1 = new SPNavigationNode("Excel 文档""/Excel/Forms/AllItems.aspx"true);
18             TopNavigation[1].Children.AddAsLast(MenuItem1);
19 
20             SPNavigationNode MenuItem2 = new SPNavigationNode("Word 文档""/Word/Forms/AllItems.aspx"true);
21             TopNavigation[1].Children.AddAsFirst(MenuItem2);
22 
23             SPNavigationNode MenuItem3 = new SPNavigationNode("Project 文档""/Project/Forms/AllItems.aspx"true);
24             TopNavigation[1].Children.AddAsFirst(MenuItem3);
25         }
26     }
27 }
28 

 

posted on 2007-11-17 21:54  左一X  阅读(362)  评论(2)    收藏  举报