Add-ons

Site Map Control

by Gabe Sumner (Sitefinity Team)
Updated on: September 1, 2009 | 24995 views

Compatibility: Version 3.5
Version: 1.0
Tags: Navigation , Free
Control that displays a full Site Map tree onto a Sitefinity page. Terms Of Use

Download from Publisher
FREE
On the Sitefinity forums Erik asked how to display an expanded Site Map. Sitefinity includes a "Site Treeview" control that comes close to accomplishing this.  However, this control starts in a "collapsed" state and I have not been able to find a way to easily coax it into an "expanded" state.

The good news is that we can create a Site Map Sitefinity UserControlfairly easily using the RadTreeView.  The control described below simply binds the ASP.NET "SiteMapDataSource" to a RadTreeView control. It then fully expands the RadTreeView.  Here is how this is done:

 

Step 1: Create the UserControl
Create the following user control file: ~/GoonDocks/UserControls/SiteMap.ascx

 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SiteMap.ascx.cs" Inherits="GoonDocks_UserControls_SiteMap" %>  
<%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="RadTreeView.NET2" %>  
<rad:radtreeview ID="SiteMapRadTreeView" EnableViewState="false" runat="server" />  

 

Create the following code-behind file: ~/GoonDocks/UserControls/SiteMap.ascx.cs 

 

using System;   
using System.Web;   
using System.Web.UI;   
using System.Web.UI.WebControls;   
using System.Web.UI.HtmlControls;   
  
public partial class GoonDocks_UserControls_SiteMap : System.Web.UI.UserControl   
{   
    protected void Page_Load(object sender, EventArgs e)   
    {   
        SiteMapRadTreeView.DataSource = new SiteMapDataSource();   
        SiteMapRadTreeView.DataBind();   
        SiteMapRadTreeView.ExpandAllNodes();   
    }   
}   

 


Step 2: Let Sitefinity know about your new UserControl

In order for Sitefinity to make use of a new UserControl it must declared in the <toolboxControls> section of the "web.config" file.  Add the following line to your "web.config" file:

<toolboxControls>  
    <add name="Site Map" section="GoonDocks" url="~/GoonDocks/UserControls/SiteMap.ascx" />     
</toolboxControls>  


Step 3: Create a new Sitefinity page and place your "Site Map" control onto the page
There is nothing that you need to edit or configure with this Site Map control.  Just plunk it onto your page and it will do its job.

3 comments

  • genarg 24 Sep 2009
    10:03 AM
    Great Control. Can we customize the [SiteMap] text?
  • Vix 06 Aug 2010
    05:47 AM
    Hi,
    Are these settings still correct for latest Sitefinity? :
    <%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="RadTreeView.NET2" %>

    Thanks!
  • Andrew 20 Aug 2010
    06:18 PM
    Vix, those are deprecated. Use this for 3.7

    <%@ Register TagPrefix="rad" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>



Add Comment

  • Providing an email will subscribe you for receving comment notifications.

  •