This documentation is archived and is not being maintained.

SiteMapDataSource.SiteMapProvider Property

Gets or sets the name of the site map provider that the data source binds to.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public virtual string SiteMapProvider { get; set; }
/** @property */
public String get_SiteMapProvider ()

/** @property */
public void set_SiteMapProvider (String value)

public function get SiteMapProvider () : String

public function set SiteMapProvider (value : String)

Not applicable.

Property Value

The name of the site map provider that the SiteMapDataSource binds to. By default, the value is Empty, and the default site map provider for the site is used.

The value of the SiteMapProvider property is stored in view state.

NoteNote:

If you are not familiar with the data access features in ASP.NET 2.0, you might find it useful to review the following topics before continuing:

TopicLocation
How to: Localize Site-Map DataBuilding ASP .NET Web Applications
How to: Localize Site-Map DataBuilding ASP .NET Web Applications

The following code example demonstrates how to declaratively bind a TreeView control to site map data that is provided by an SiteMapProvider object other than the default provider. The site is configured to access a custom SiteMapProvider object though the following Web.config file:

<system.web>    
  <siteMap>
    <provider
      name="AsciiTextProvider"
      type="Samples.AspNet.Controls.SimpleTextSiteMapProvider,Samples.AspNet"
      siteMapFile="test.txt"/>                
  </siteMap>
NoteNote:

The AsciiTextProvider is not the default provider for the site, which (in this case) remains the XmlSiteMapProvider object. The SiteMapProvider property of the SiteMapDataSource control is set to the name of a custom site map provider, and the TreeView binds to the corresponding site map data.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:SiteMapDataSource
                id="SiteMapDataSource1"
                runat="server"
                SiteMapProvider="AsciiTextProvider" />

            <asp:TreeView
                id="TreeView1"
                runat="server"
                DataSourceID="SiteMapDataSource1">
            </asp:TreeView>

        </form>
    </body>
</html>

<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:SiteMapDataSource
                id="SiteMapDataSource1"
                runat="server"
                SiteMapProvider="AsciiTextProvider">
            </asp:SiteMapDataSource>

            <asp:TreeView
                id="TreeView1"
                runat="server"
                DataSourceID="SiteMapDataSource1">
            </asp:TreeView>

        </form>
    </body>
</html>

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: