Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > Editor > Add SiteMap to Custom Links Dropdown

Add SiteMap to Custom Links Dropdown

Feed from this thread
  • Sam Miller avatar

    Posted on Jan 24, 2007 (permalink)

    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


     
  • 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!

Reply

  • Rumen Rumen admin's avatar

    Posted on Jan 29, 2007 (permalink)

    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

    Reply

  • Jason Miller avatar

    Posted on Mar 3, 2007 (permalink)

    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

    Reply

  • Petya Petya admin's avatar

    Posted on Mar 5, 2007 (permalink)

    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

    Reply

  • George George admin's avatar

    Posted on Feb 19, 2008 (permalink)

    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

    Reply

  • Back to Top

    Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > Editor > Add SiteMap to Custom Links Dropdown