MOSS的导航菜单默认只支持两级,但是MOSS的导航API实际上是支持无限级的,比如可以用以下代码添加三级导航栏:
using (SPSite site = new SPSite("http://codeart:81"))
{
using (SPWeb web = site.RootWeb)
{
web.AllowUnsafeUpdates = true;
Microsoft.SharePoint.Navigation.SPNavigation sp = web.Navigation;
SPNavigationNode spn = new SPNavigationNode("Google", "www.google.com", true);
SPNavigationNode spn2 = new SPNavigationNode("Google1", "www.google.com", true);
SPNavigationNode spn3= new SPNavigationNode("Google2", "www.google.com", true);
sp.QuickLaunch.AddAsLast(spn);
spn.Children.AddAsLast(spn2);
spn2.Children.AddAsLast(spn3);
web.Update();
}
}
这样添加了三级导航菜单之后,系统默认的界面依然显示不出来。
我们只能通过自己开发导航控件的方式来实现这一点。代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;
namespace CodeArt.SharePoint.WebParts
{
public class NavigationMenu : Menu
{
protected override void CreateChildControls()