Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [189]

By Root 5577 0
collection of node objects that contain properties for each node in the map. The class is instantiated and populated when the application starts up; the data loaded is cached and refreshed care of the provider. In particular, the XML site map provider monitors the site map file for changes and refreshes itself accordingly.

Table 8-5 shows and describes the syntax and behavior of the members featured by the SiteMap class.

Table 8-5. Members of the SiteMap Class

Member

Description

CurrentNode

A property that returns the SiteMapNode object that represents the currently requested page.

Enabled

A property that indicates whether a site map provider is enabled.

Provider

A property that returns the SiteMapProvider object that indicates the provider being used for the current site map.

Providers

A property that returns a read-only collection of SiteMapProvider objects that are available to the application.

RootNode

A property that returns a SiteMapNode object that represents the root page of the navigation structure built for the site.

SiteMapResolve

An event that occurs when the CurrentNode property is accessed. Whether this event is really raised or not depends on the particular provider being used. It does fire for the default site map provider.

The SiteMap class retrieves the CurrentNode property by making a request to the provider. A null value is returned if no node exists for the requested page in the site map, or if role information for the current user doesn’t match the role enabled on the node.

The SiteMapPath Control


A site map path is the overall combination of text and links that appears in some pages to indicate the path from the home page to the displayed resource—the classic page breadcrumb. (See Figure 8-11.)

Figure 8-11. Path to the currently displayed page.

ASP.NET provides a made-to-measure navigation path control—the SiteMapPath control—that supports many options for customizing the appearance of the links.

SiteMapPath reflects node data supplied by the SiteMap object. The control takes limited space in the page and makes parent pages of the current page only one click away. Table 8-6 shows the properties supported by the SiteMapPath control.

Table 8-6. Properties of the SiteMapPath Control

Method

Description

CurrentNodeStyle

The style used to render the display text of the current node

CurrentNodeTemplate

The template to use to represent the current node in the site navigation path

NodeStyle

The style used to render the display text for all nodes in the site navigation path

NodeTemplate

The template used to represent all the functional nodes in the site navigation path

ParentLevelsDisplayed

The number of levels of parent nodes displayed, relative to the current node

PathDirection

Gets or sets the order for rendering the nodes in the navigation path

PathSeparator

The string used to delimit nodes in the rendered navigation path

PathSeparatorStyle

The style used for the PathSeparator string

PathSeparatorTemplate

The template used to render the delimiter of a site navigation path

Provider

The site map provider object associated with the control

RenderCurrentNodeAsLink

If set, causes the control to render the current node as a hyperlink

RootNodeStyle

The style for the display text of the root node

RootNodeTemplate

The template used for the root node of a site navigation path

ShowToolTips

If set, displays a ToolTip when the mouse hovers over a hyperlinked node

SiteMapProvider

Gets or sets the name of the site map provider object used to render the site navigation control

SkipLinkText

Gets or sets the value used to render alternate text for screen readers to skip the control’s content

The SiteMapPath control works by taking the URL of the current page and populating an instance of the SiteMapNode class with information obtained from the site map. Retrieved information includes the URL, title, description, and location of the page in the navigation hierarchy. The node is then rendered out as a sequence

Return Main Page Previous Page Next Page

®Online Book Reader