Solved

Reading and loop in web.sitemap in C#

Posted on 2010-09-17
2
1,501 Views
Last Modified: 2012-06-21
Hi,

I am working in ASP.net using c#

I have generated menu and navgation  using web.sitemap

How do I loop to web.sitemap programtically and get the values of each attrbutes and tag values

Please help

Many Thanks
0
Comment
Question by:tia_kamakshi
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 33707996
A simple recursive loop should do the trick:

 
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteMapNode rootNode = SiteMap.RootNode;
            ProcessNode(rootNode);

        }

        private void ProcessNode(SiteMapNode parentNode)
        {
            Response.Write(parentNode.Url + " (" + parentNode.Title + ")<br />");

            if (parentNode.HasChildNodes)
                foreach (SiteMapNode node in parentNode.ChildNodes)
                    ProcessNode(node);
        }

Open in new window

0
 

Author Closing Comment

by:tia_kamakshi
ID: 33735285
Many Thanks
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question