Edit

Share via


SiteMapDataSource.SiteMapProvider Property

Definition

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

public:
 virtual property System::String ^ SiteMapProvider { System::String ^ get(); void set(System::String ^ value); };
public virtual string SiteMapProvider { get; set; }
member this.SiteMapProvider : string with get, set
Public Overridable Property SiteMapProvider As String

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.

Examples

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 Web.config file makes a custom SiteMapProvider object available to the SiteMapDataSource control:

<system.web>      
  <siteMap>  
    <providers>  
      <add name="AsciiTextProvider"  
        description="SiteMap provider which reads in .sitemap text files."  
        type="Samples.AspNet.CS.SimpleTextSiteMapProvider"  
      siteMapFile="test.txt"/>  
    </providers>  
  </siteMap>  
</system.web>  

The code for the SimpleTextSiteMapProvider class that this Web.config file example references can be found in the SiteMapProvider class overview. If you use the Visual Basic example, the namespace ends in "VB" instead of "CS". You can also find sample content for the "text.txt" site map file in the SiteMapProvider class overview.

Note

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="VB" %>
<!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>

Remarks

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

Applies to

See also