다음을 통해 공유


SPNavigation.QuickLaunch Property

Gets an Microsoft.SharePoint.Navigation.SPNavigationNodeCollection object that contains the nodes in the Quick Launch area of the site.

Namespace:  Microsoft.SharePoint.Navigation
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableAttribute> _
Public ReadOnly Property QuickLaunch As SPNavigationNodeCollection
    Get
'Usage
Dim instance As SPNavigation
Dim value As SPNavigationNodeCollection

value = instance.QuickLaunch
[ClientCallableAttribute]
public SPNavigationNodeCollection QuickLaunch { get; }

Property Value

Type: Microsoft.SharePoint.Navigation.SPNavigationNodeCollection
The navigation nodes in the Quick Launch area.

Remarks

The navigation nodes returned by this property are represented as headings in the Quick Launch area of the user interface. To modify the links below a heading, first get the SPNavigation object that represents the heading, then access that object's Children property to enumerate the collection of navigation nodes below the heading.

You can hide the Quick Launch area by setting the SPWeb.QuickLaunchEnabled property to false.

Examples

The following example is a console application that prints information about each heading in the Quick Launch area and about any items under each heading.

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.OpenWeb("/"))
                {
                    foreach (SPNavigationNode heading in web.Navigation.QuickLaunch)
                    {
                        Console.WriteLine("\n{0} [{1}]", heading.Title, heading.Url);

                        foreach (SPNavigationNode child in heading.Children)
                            Console.WriteLine(" {0} [{1}]", child.Title, child.Url);
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.ReadLine();
        }
    }
}
Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Navigation

Module ConsoleApp

    Sub Main()

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

            Using web As SPWeb = site.OpenWeb("/")

                For Each heading As SPNavigationNode In web.Navigation.QuickLaunch
                    Console.WriteLine(vbLf & "{0} [{1}]", heading.Title, heading.Url)

                    For Each child As SPNavigationNode In heading.Children
                        Console.WriteLine(" {0} [{1}]", child.Title, child.Url)
                    Next
                Next

            End Using

        End Using

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

End Module

See Also

Reference

SPNavigation Class

SPNavigation Members

Microsoft.SharePoint.Navigation Namespace

Microsoft.SharePoint.Navigation.SPNavigationNodeCollection

Microsoft.SharePoint.Navigation.SPNavigationNode