This is a migrated thread and some comments may be shown as answers.

RadMenu and WebAii Framework

2 Answers 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Cathy
Top achievements
Rank 1
Cathy asked on 12 Sep 2012, 05:01 PM
Using WebAii framework and C#, I am trying to iterate through all of the menu items to validate access for our application WITHOUT knowing what's there.  I can get the root and children but am having a hard time getting ChildNodes of a Child or going 3 levels deep.  Here's the code I am having an issue with...  I can't seem to figure out how to get the 3rd level and I'm sure it's something simple I am overlooking.  Thanks in advance!

foreach (RadMenuItem rootitem in menu.RootItems)
            {
                string menuHeader = rootitem.Text;
                Log.WriteLine("The menu header is - " + menuHeader);
                RadMenuItem menuList = menu.FindItemByText(menuHeader);
                foreach (RadMenuItem childitem in menuList.Items)
                {
                    string chldItem = childitem.Text;
                    Log.WriteLine(menuHeader + " - " + chldItem);
                    if (childitem.HasChildren)
                    {
                        int c = childitem.ChildNodes.Count;
                        for (int i = 1; i <= c; i++)
                        {
                            string childChild = ****CAN'T FIGURE THIS CODE OUT****
                            Log.WriteLine(menuHeader + " - " + chldItem + " - " + childChild);
                        }
                    }
  
                }
  
            }





2 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 18 Sep 2012, 01:15 PM
Hello Cathy,

I apologize for the delay in getting back to you on this.

Please try the following code that succeeded against this RadMenu demo website and let me know if you need further assistance.
RadMenu menu = ActiveBrowser.Find.ById<RadMenu>("RadMenu1");
 
foreach (RadMenuItem rootitem in menu.RootItems)
{
    string menuHeader = rootitem.Text;
    Log.WriteLine("The menu header is - " + menuHeader);
    RadMenuItem menuList = menu.FindItemByText(menuHeader);              
 
    foreach (RadMenuItem childitem in menuList.Items)
    {              
        string chldItem = childitem.Text;
        Log.WriteLine(menuHeader + " - " + chldItem);
 
        if (childitem.HasChildren)
        {
            int c = childitem.Items.Count;
            for (int i = 0; i < c; i++)
            {
 
                string childChild = childitem.Items[i].Text;
 
                Log.WriteLine(menuHeader + " - " + chldItem + " - " + childChild);
 
            }
 
        }
 
    }
 
}


All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Cathy
Top achievements
Rank 1
answered on 18 Sep 2012, 06:05 PM
Thanks Plemen, that was what I needed.

Tags
General Discussions
Asked by
Cathy
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Cathy
Top achievements
Rank 1
Share this question
or