RadMenu and WebAii Framework

3 posts, 1 answers
  1. Cathy
    Cathy avatar
    2 posts
    Member since:
    Jul 2012

    Posted 12 Sep 2012 Link to this post

    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. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 18 Sep 2012 Link to this post

    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
  3. Cathy
    Cathy avatar
    2 posts
    Member since:
    Jul 2012

    Posted 18 Sep 2012 Link to this post

    Thanks Plemen, that was what I needed.

Back to Top