RadMenu for ASP.NET

Telerik RadMenu Client-Side API Send comments on this topic.
See Also
Telerik RadMenu client-side > Telerik RadMenu Client-Side API

Glossary Item Box

Telerik RadMenu provides a flexible client-side API. You can easily interact with the menu in the browser using the menu client-side object.

1. Getting the RadMenu client-side object

RadMenu creates a client-side object with the ClientID of the menu. You can obtain the reference using the following JavaScript code:

  Copy Code
var menu = <%= RadMenu1.ClientID %>;

2. Getting the instance of a particular RadMenuItem

Once you get the client-side object of RadMenu, you can use the FindItemByText() method to get the instance of a particular item. Example:

  Copy Code
var menu = <%= RadMenu1.ClientID %>;
var item
= menu.FindItemByText(text);

3. Calling a client-side method

When you get the instance of a particular item, you can call a client-side method to perform a task. Consider the following examples:

  • Open()
  Copy Code
function OpenItem()
{
   var menu = <%= RadMenu1.ClientID %>;
   var item
= menu.FindItemByText(text);
   
if (item)
   {
       
item.Open();
   }
   
else
   {
       
alert("Item with text '" + text + "' not found.");
   }
}

 

  • Close()
  Copy Code
function CloseItem()
{
   var menu = <%= RadMenu1.ClientID %>;   
   var item
= menu.FindItemByText(text);
   
if (item)
   {
       
item.Close();
   }
   
else
   {
       
alert("Item with text '" + text + "' not found.");
   }
}

 

  • Disable()
  Copy Code
function DisableItem()
{
   var menu = <%= RadMenu2.ClientID %>;
   var item
= menu.FindItemByText(text);
   
if (item)
   {
       
item.Disable();
   }
   
else
   {
       
alert("Item with text '" + text + "' not found.");
   }
}

 

  • Enable()
  Copy Code
function EnableAll()
{
   var menu = <%= RadMenu2.ClientID %>;
   
for (var i = 0; i < menu.AllItems.length; i++)
   {
       
menu.AllItems[i].Enable();
   }
}

 

The code block <%= ... %> needs to be placed inside the BODY element of the page. See Atlas support for details.

See Also