1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / ListDisplay with SiteMapDataSource

ListDisplay with SiteMapDataSource

4 posts, 0 answered
  1. Chad
    Chad avatar
    2 posts
    Registered:
    17 Jul 2008
    30 Jul 2009
    Link to this post
    Ok, I'm new to sitefinity development and hopefully this is an easy question.  I want to use the sitemapdatasource with the listdisplay control.  Ultimately I just want a layout like this
    <ul>
      <li><a href="whatever">whatever</a></li>
      <li><a href="whatever">whatever</a></li>
      ...
    </ul>

    I don't want any extra div or span tags you get with the radmenu.  Can the sitemapdatasource be used against the listdisplay or do I need to create a custom control.  And if I need to create a custom control that hits the sitemapdatasource then where should I begin?  Thanks

    -chad
  2. Nikolai
    Nikolai avatar
    216 posts
    Registered:
    24 May 2017
    31 Jul 2009
    Link to this post
    Hi Chad,

    Why don't you create a very basic custom control like this:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %> 
     
     <ul runat="server" id="uList"
             
     </ul>   
     

    and then on the page Load event set:
    protected void Page_Load(object sender, EventArgs e) 
        { 
            var siteMap = SiteMap.Provider; 
            foreach(SiteMapNode item in siteMap.RootNode.GetAllNodes()) 
            { 
                var str = "<li><a href=\"" + item.Url + "\">" + item.Title + "</a></li>"
                uList.InnerHtml = uList.InnerHtml + str; 
            } 
             
        } 

    That way you can always control the outputted Html by just changing the "str" variable value.

    Kind regards,
    Nikolai
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Chad
    Chad avatar
    2 posts
    Registered:
    17 Jul 2008
    06 Aug 2009
    Link to this post
    Thanks for your help.  Ultimately I want to use the sitemapdatasource so the user can have some level of control over which pages are displayed in the list but for now I'm just going to hard-code it to a subset of the sitemap with a listview.  Are there any examples available showing integration of a sitemapdatasource with a user control?
  4. Nikolai
    Nikolai avatar
    216 posts
    Registered:
    24 May 2017
    10 Aug 2009
    Link to this post
    Hello Chad,

    You can take a look in your project's "~\Sitefinity\UserControls\Navigation35" folder. Each user control there is actually wrapper of a Rad Control that uses "Sitemap" as data source.

    Kind regards,
    Nikolai
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Register for webinar
4 posts, 0 answered