PortalSiteMapProvider.GetChildNodes method (PortalSiteMapNode, NodeTypes, NodeTypes, OrderingMethod, AutomaticSortingMethod, Boolean, Int32)

Returns a sorted, security-trimmed collection of child nodes for a specified parent node, types of nodes to include, types of hidden nodes to include, and sorting options.

Namespace:  Microsoft.SharePoint.Publishing.Navigation
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

public virtual SiteMapNodeCollection GetChildNodes(
	PortalSiteMapNode node,
	NodeTypes includedTypes,
	NodeTypes includedHiddenTypes,
	OrderingMethod ordering,
	AutomaticSortingMethod method,
	bool ascending,
	int lcid
)

Parameters

node
Type: Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode

The node whose child nodes are returned.

includedTypes
Type: Microsoft.SharePoint.Publishing.NodeTypes

The types of child nodes to return.

includedHiddenTypes
Type: Microsoft.SharePoint.Publishing.NodeTypes

The types to return even if hidden.

ordering
Type: Microsoft.SharePoint.Publishing.OrderingMethod

The type of ordering to use.

method
Type: Microsoft.SharePoint.Publishing.AutomaticSortingMethod

The method of sorting to use with automatic sorting.

ascending
Type: System.Boolean

Whether to use ascending or descending order.

lcid
Type: System.Int32

The locale ID to use for culture sorting.

Return value

Type: System.Web.SiteMapNodeCollection
A collection of child nodes of types specified that are sorted as specified.

The following example references the following assemblies:

  • System.dll

  • System.Data.dll

  • System.Xml.dll

  • System.Web.dll

  • System.Configuration.dll

  • Microsoft.SharePoint.dll

  • Microsoft.SharePoint.Library.dll

  • Microsoft.SharePoint.Publishing.dll

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Publishing.Navigation;

namespace Microsoft.SDK.SharePointServer.Samples
{
    class GetChildNodesSample
    {
        // Get a list of the navigation headings beneath a specified
        // Web site in current navigation. This method must be called from
        // within a current and valid HttpContext object.
        public static List<string>GetNavigationHeadingTitles(string serverRelativeWebUrl)
        {
            List<string> titles = null;

            // Get a reference to the current navigation provider:
            // the one that doesn't HTML-encode titles.
            PortalSiteMapProvider portalProvider = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;
            // lookup the node for the given Web site URL.
            PortalWebSiteMapNode webNode = 
                portalProvider.FindSiteMapNode(serverRelativeWebUrl) as PortalWebSiteMapNode;

            if (webNode != null)
            {
                // Retrieve the heading nodes beneath the 
                // specified Web site.
                SiteMapNodeCollection headingNodes = 
                    portalProvider.GetChildNodes(webNode, NodeTypes.Heading, NodeTypes.None);

                titles = new List<string>(headingNodes.Count);

                foreach (PortalSiteMapNode headingNode in headingNodes)
                {
                    // Add the title to the list.
                    titles.Add(headingNode.Title);
                }
            }

            // Return the list of titles.
            return titles;
        }
    }
}
Show: