共用方式為


SPContentMapProvider Class

Provides methods and properties for implementing a site map provider for contents of a Microsoft SharePoint Foundation site. This class provides the SiteMapNode objects that constitute the content portion of the breadcrumb, where "content" refers to the lists, folders, items, and list forms composing the breadcrumb.

Inheritance Hierarchy

System.Object
  System.Configuration.Provider.ProviderBase
    System.Web.SiteMapProvider
      Microsoft.SharePoint.Navigation.SPContentMapProvider

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

Syntax

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class SPContentMapProvider _
    Inherits SiteMapProvider
'Usage
Dim instance As SPContentMapProvider
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SPContentMapProvider : SiteMapProvider

Examples

The SPContentMapProvider class allows you to write custom controls to navigate a site. The following sample code displays the name of the nodes that you retrieve by using various methods of the provider.

<% @Page language="C#" Debug=true%>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint"
      Assembly="Microsoft.Sharepoint" %>
<%@ Register Tagprefix="SharePointNavigation"
      Namespace="Microsoft.SharePoint.Navigation"
      Assembly="Microsoft.Sharepoint" %>
<%@ Register Tagprefix="SharePointWebControls"
      Namespace="Microsoft.SharePoint.WebControls"
      Assembly="Microsoft.Sharepoint" %>
<HTML>
     <BODY>
            Tests the SPContentMapProvider properties
            <BR>
            <%

SPWeb web = SPControl.GetContextWeb(Context);

SPContentMapProvider prov =
     (SPContentMapProvider)SiteMap.Providers["SPContentMapProvider"];

Response.Write ("<BR><DIV ID =\"context\">" +
      prov.FindSiteMapNode(Context) + "</DIV>");
Response.Write("<BR><DIV ID=\"url\">" + 
      prov.FindSiteMapNode(web.Url) + "</DIV>");
Response.Write("<BR><DIV ID=\"key\">" +
      prov.FindSiteMapNodeFromKey(web.ID.ToString()) + "</DIV>");
Response.Write("<BR><DIV ID=\"children\">" +
      prov.GetChildNodes(prov.CurrentNode).Count + "</DIV>");

%>
     </BODY>
</HTML>

Thread Safety

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

See Also

Reference

SPContentMapProvider Members

Microsoft.SharePoint.Navigation Namespace

System.Web.SiteMapProvider

Other Resources

Website Navigation