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

How to get parent menu item text from radmenuitem click event

1 Answer 452 Views
Menu
This is a migrated thread and some comments may be shown as answers.
VIJESH
Top achievements
Rank 1
VIJESH asked on 10 Apr 2013, 01:35 PM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 12 Apr 2013, 12:07 PM
Hello,

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;
       }   
   }

Regards,
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.
Tags
Menu
Asked by
VIJESH
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or