Asp – Generate A-Z from ASP.NET SiteMap

asp.netsitemap

I wish to generate an A-Z from a SiteMap… I do not use the Web.SiteMap directly, rather a StaticSiteMapProvider, based on this blog post by Simon Harriyott: Adding dynamic nodes to ASP.NET site maps at runtime by deriving from StaticSiteMapProvider

How can I go about doing this?

Edit:

I want an A-Z list, by link title. Could be starting at the root node or any child node. I also want to bind to a repeater and limit which pages to show (for example, don't show links with 'admin' or 'profile' in the URL).

Using .NET 2.0, so no LINQ code.

Best Answer

I'm not exactly sure what you mean by an "A-Z". I think what you mean is you want an alphabetized list of all pages in your SiteMap? If so then this might help.

        var NodesAtoZ = from SiteMapNode node in SiteMap.RootNode.GetAllNodes()
                    orderby node.Title
                    select new
                    {
                        Title = node.Title,
                        Url = node.Url,
                        Description = node.Description
                    };

This returns a list of all SiteMap nodes ordered by Title.

Related Topic