Export (0) Print
Expand All

SPNavigationNode class

Represents a node in a hierarchical navigation structure for a Microsoft SharePoint Foundation Web site.

System.Object
  Microsoft.SharePoint.Navigation.SPNavigationNode

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

'Declaration
Public NotInheritable Class SPNavigationNode
'Usage
Dim instance As SPNavigationNode

Unlike the SPNavigationNodeCollection class, the SPNavigationNode class requires you to call the Update method to cause property changes to existing nodes to be saved to the database. However moves occur immediately.

The following console application prints a simple map of the navigation structure for a Web site.

Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Navigation

Module ConsoleApp

    Sub Main()

        Using site As New SPSite("http://localhost")

            Using web As SPWeb = site.OpenWeb()

                Dim format As String = "|-{0} (Id = {1})"

                For Each globalNode As SPNavigationNode In web.Navigation.GlobalNodes
                    Console.WriteLine(format, globalNode.Title, globalNode.Id)

                    For Each childNode As SPNavigationNode In globalNode.Children
                        Console.WriteLine("  " + format, childNode.Title, childNode.Id)
                    Next
                    Console.WriteLine("|")
                Next

            End Using

        End Using

        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft