Add SiteMap to Custom Links Dropdown

Thread is closed for posting
5 posts, 0 answers
  1. 3C6AF918-6E09-44EE-AB6F-53F60DA12305
    3C6AF918-6E09-44EE-AB6F-53F60DA12305 avatar
    6 posts
    Member since:
    Jan 2007

    Posted 24 Jan 2007 Link to this post

    Requirements

    r.a.d.controls version

    6.x - 7.x

    .NET version

    2.0

    Visual Studio version

    2005

    programming language

    C#

    browser support

    all browsers supported by r.a.d.controls


     
  2. PROJECT DESCRIPTION
    I needed a way to display all the links available on my client's sitemap in the links dropdown. 

    This is code to bind the "Custom Links" drop down in your editor to your site's sitemap provider, if you are using one. 

    <script runat="server">  
        protected override void OnLoad(EventArgs e)  
        {  
            base.OnLoad(e);  
            if (!IsPostBack)  
            {  
                editor1.Links.Clear();  
                BindLinks(editor1.Links, SiteMap.RootNode);  
            }  
        }  
     
        private void BindLinks(Link parentLink, SiteMapNode siteMapNode)  
        {  
            Link currentLink = new Link(siteMapNode.Title, siteMapNode.Url, "", siteMapNode.Description);  
            parentLink.Add(currentLink);  
            for (int i=0; i<siteMapNode.ChildNodes.Count; i++)  
            {  
                BindLinks(currentLink, siteMapNode.ChildNodes[i]);  
            }  
        }  
    </script> 

    <

    RadE:RadEditor ID="editor1" runat="server"></RadE:RadEditor>



    To run the example, just copy the attached aspx page in the root of your web site, having RadEditor in it, and load it in your browser.

    And bingo, you have the sitemap content in your Custom Links box.

    Enjoy!
  • DF60784D-55A5-4263-9F10-A12FA48C9ADC
    DF60784D-55A5-4263-9F10-A12FA48C9ADC avatar
    14477 posts
    Member since:
    Apr 2022

    Posted 29 Jan 2007 Link to this post

    Hi Sam,

    Thank you for sharing your idea with us. We have updated your code and attached the new zip to your post.

    As a small token of gratitude for your code library solution we have added 1500 telerik points to your account.

    Best regards,
    Rumen
    the telerik team
  • 76F23616-382F-4BB9-BF9C-AC01BE59F876
    76F23616-382F-4BB9-BF9C-AC01BE59F876 avatar
    8 posts
    Member since:
    Oct 2006

    Posted 03 Mar 2007 Link to this post

    Nice example I had been doing this manually iterating through the node list.

    I converted your example to code behind in VB for anyone who needs it in VB instead.

    #Region "SET RAD EDITOR VALUES"

    Private Sub GetSiteMap()

    'Clear our links and set our sitemap

    RadEditor1.Links.Clear()

    'Recursively process our Sitemap into our RadEditor

    SetRadLinks(RadEditor1.Links, SiteMap.RootNode)

    End Sub

    Private Sub SetRadLinks(ByVal ParentLink As Telerik.WebControls.RadEditorUtils.Link, ByVal mySiteMapNode As SiteMapNode)

    Dim I As Int32 = 0

    Dim CurrentLink As Telerik.WebControls.RadEditorUtils.Link = New Telerik.WebControls.RadEditorUtils.Link(mySiteMapNode.Title, mySiteMapNode.Url, "", mySiteMapNode.Description)

    ParentLink.Add(CurrentLink)

    'Loop through our Child Links

    For I = 0 To (mySiteMapNode.ChildNodes.Count - 1)

    SetRadLinks(CurrentLink, mySiteMapNode.ChildNodes(I))

    Next

    End Sub

    #End Region

  • 2684DEE8-E2BA-4682-A7A5-40FF71873DCD
    2684DEE8-E2BA-4682-A7A5-40FF71873DCD avatar
    869 posts
    Member since:
    Sep 2012

    Posted 05 Mar 2007 Link to this post

    Hi,

    Thank you for being so active and sharing with the telerik community. As a small way to thank you, please find 500 points added to your account.

    Greetings,
    Petya
    the telerik team
  • 58D3E524-F6D0-4E4F-AD08-31E6FD9A8B36
    58D3E524-F6D0-4E4F-AD08-31E6FD9A8B36 avatar
    859 posts
    Member since:
    Sep 2012

    Posted 19 Feb 2008 Link to this post

    Hi,

    Please, find the project updated with RadEditor "Prometheus" in the first post as well.

    Kind regards,
    George
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  • Back to Top

    This Code Library is part of the product documentation and subject to the respective product license agreement.