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

Detect RadMenu's container

1 Answer 62 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Meaning Of Lights
Top achievements
Rank 2
Meaning Of Lights asked on 23 Apr 2008, 02:09 AM
Hi,

How do I get the container of RadMenu? eg

The code below removes the Menu not its container as well:
function OnClicking(sender, eventArgs)
{
var proceed = confirm("Are you sure you want to delete?");
if (!proceed)
{
return false;
}
else
{
alert(eventArgs.Item.Parent.LinkElement.id);
var ctrl = document.getElementById(eventArgs.Item.Parent.LinkElement.id);
ctrl.parentNode.removeChild(ctrl);
}


I want it to be:
ctrl.parentNode.PARENT.removeChild(ctrl);




More info:
My page consists of UserControls that users can reposition in the page.

Each UserControl has a Rad Menu. When a user swaps around 2 UserControls the radmenu.parent.parent result is incorrect because jquery modified the client-side html but the server-side isn't aware.Therefore using server-side code doesn't work,eg:

RadMenu_ItemClick(object sender, RadMenuEventArgs e)
{
 RadMenu radmenu = (RadMenu)sender;

MyUserControl myusercontrol = (MyUserControl)radmenu.Parent.Parent;


when 2 modules swap each others place on a page the myusercontrol is the wrong control.

Hence I'm trying to get the client side method to work, but for the life of me I cant work out how to detect the UserControl that a RadMenu's sits it.

Any help would be much appreciated

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Apr 2008, 06:32 AM
Hi Jeremy,

In RadMenu "Classic" you can use the DomElement field which represents the root tag of RadMenu. Then using the parentNode property you can access the HTML element which contains your RadMenu. Here is some sample code:

var menu = <%= RadMenu1.ClientID %>;
var parent = menu.DomElement.parentNode;

In RadMenu for ASP.NET Ajax you can use the get_element() property to access the root tag of RadMenu. Again you can use parentNode to get the HTML element which contains that menu instance.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Menu
Asked by
Meaning Of Lights
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Share this question
or