PotalSiteMapProvider不返回页面。我使用如下代码:
PortalSiteMapProvider prov = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;
prov.DynamicChildLimit = 0;
prov.IncludeSubSites = PortalSiteMapProvider.IncludeOption.Always;
prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
prov.IncludeHeadings = true;
prov.IncludeAuthoredLinks = true;
SiteMapNode root = prov.RootNode;
//prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
SiteMapNodeCollection collection = prov.GetChildNodes(root);
foreach (SiteMapNode thisNode in collection)
{
SiteMapNodeCollection thisCollection;
if (thisNode.GetType() == typeof(PortalWebSiteMapNode))
{
prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
thisCollection = prov.GetChildNodes((PortalWebSiteMapNode)thisNode);
}
}
当我通过调试器查看时,thisCollection从未有任何子节点,尽管thisNode是具有页面的SubSite节点。我做错了什么以及如何获取该节点中的页面? 谢谢!
答案 0 :(得分:0)
这是我之前在项目中使用的代码。它似乎适合我的子页面。
PortalSiteMapProvider portalProvider = (PortalSiteMapProvider)SiteMap.Providers["CurrentNavSiteMapProviderNoEncode"];
PortalSiteMapNode currentNode = portalProvider.CurrentNode as PortalSiteMapNode;
foreach (SiteMapNode childNode in currentNode.ChildNodes) {
...
}