Custom attributes are a convenient way to store custom data for menu items.
There are three ways of defining custom attributes:
- Define custom attributes inline (in the ASPX/ASCX file)
<telerik:RadMenuItem State="unchecked" Text="Bold" ></telerik:RadMenuItem>
- Define custom attributes in the code-behind.
[C#]
RadMenuItem item = new RadMenuItem();
item.Attributes["State"] = "unchecked";
[VB]
Dim item As RadMenuItem = New RadMenuItem()
item.Attributes("State") = "unchecked"
- Define custom attributes at the client-side:
<script type="text/javascript">
function toggleCheck (sender, args)
{
var item = args.get_item();
//Pass the "AttributeName" and "AttributeValue" as parameters of the setAttribute method
item.get_attributes().setAttribute("State", "checked");
//You can obtain the value of a custom attribute like shown below
//Pass the "AttributeName" as a parameter of the getAttribute method:
var state = item.get_attributes().getAttribute("State");
}
</script>