I'm building a website that uses the SiteMap, employing SiteMap Files for subdirectories. What I want to do is to randomly pull 3 URLs from the entire sitemap, sans whatever current directory the browser is in. I've got a root siteMapNode, then several child nodes, one for each subdirectory on the site.
For example, lets say my SiteMap has a root node, then 3 subdirectories named X, Y, and Z (there are actually many more, but this will suffice). The client has navigated to a page in subdirectory X. In this case I want to pull 3 random nodes from directories outside X, which would be Root, Y, or Z. Additionally, I'll want to exclude a few pages, like "Legal" or "Contact". Then I'll display the randomly selected nodes as links.
I want to get opinions on a clean, efficient way to do this. Here are 2 approaches I'm considering:
- Create a navigation DataSet with a DataTable containing the columns ID, URL, Title, and Description. Write a method that loads all the SiteMap nodes into an AllNodes navigation dataset, randomly pick 3 of those from that AllNodes set, and return the 3 selected nodes as a navigation DataSet from the method. To do this I'll need a good example of iterating through all the nodes in a SiteMap.
- Leverage a TreeView control that doesn&
View Complete Post