How to get parent menu item text from radmenuitem click event

2 posts, 1 answers
    VIJESH avatar
    13 posts
    Member since:
    Oct 2012

    Posted 10 Apr 2013 Link to this post

    I have a radmenu control with menus such as "Skin", "Links" etc. Skin menu having child items such as "Forest", "Black", "Default" etc.
    If I selected Forest, I'm getting it from radmenu1_itemClick event using the code - "e.Item.Text". But in my case, if I select Forest, I need to check some condition using it's parent (here "Skin") text from the code.
  2. Answer
    Boyan Dimitrov
    Boyan Dimitrov avatar
    1968 posts

    Posted 12 Apr 2013 Link to this post


    An easy and convenient way of achieving such functionality would be to use the .Parent property of the clicked item and access its text property if the returned parent control is RadMenuItem type.
    //code behind
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
           Control parentControl = e.Item.Parent;
           if (parentControl.GetType() == typeof(RadMenuItem))
               RadMenuItem parentMenuItem = e.Item.Parent as RadMenuItem;
               string parentMenuItemText = parentMenuItem.Text;

    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top