RadMenu for ASP.NET

Overview Send comments on this topic.
See Also
Custom Attributes > Overview

Glossary Item Box

It is not always possible to provide all properties that might be needed for certain type of scenarios. That is why menu items(RadMenuItem) provide a special collection called Attributes. You can store any number of attributes in the collection as name/value pairs.


You can set or access custom attributes in one of the following ways:

ASPX/ASCX file

 Copy Code
<rad:RadMenuItem State="unchecked" Text="Bold"></rad:RadMenuItem>
        

Code-behind

You can also set custom attributes from code behind via the Attributes collection exposed by the RadMenuItem class.

C# Copy Code
RadMenuItem item = new RadMenuItem();
item.Attributes
["State"] = "unchecked";
        
VB.NET Copy Code
Dim item As RadMenuItem = New RadMenuItem()
item.Attributes("State") = "unchecked"

Client-side

To set the value of a custom attribute on the client-side you should use the SetAttribute method.

 Copy Code
<script type="text/javascript">
function ToggleCheck (sender, args)
{
var item = args.Item;
item.SetAttribute(
"State", "checked");
}
</script>
        

To get the value of a custom attribute on the client-side you should use the GetAttribute method.

 Copy Code
<script type="text/javascript">
function ToggleCheck (sender, args)
{
var item = args.Item;
var state
= item.GetAttribute("State");
}
</script>
        

 

See Also