<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="RadMenu.Net2" Namespace="Telerik.WebControls" TagPrefix="radM" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <script type="text/javascript">
        function OpenItem( OpenIt )
        {
            var menu = <%= RadMenu1.ClientID %>;
            var text = document.getElementById("TextBox1").value;  
              
            var item = menu.FindItemByText(text);
            if (item)
            {
                if ( OpenIt )
                    item.Open();
                else
                    item.Close(); 
            }
            else
            {
                alert("Item with text '" + text + "' not found.");
            }
        }

        function EnableItem( EnableIt )
        {
            var menu = <%= RadMenu1.ClientID %>;
            var text = document.getElementById("TextBox1").value;  
              
            var item = menu.FindItemByText(text);
            if (item)
            {
                if ( EnableIt )
                    item.Enable();
                else
                    item.Disable(); 
            }
            else
            {
                alert("Item with text '" + text + "' not found.");
            }
        }

        function EnumerateAllItems()
        {
            var menu = <%= RadMenu1.ClientID %>;
            for (var i=0; i<menu.AllItems.length; i++)
                {
                   alert(menu.AllItems[i].Text);
                }
         }    
    </script>
    <div>
        <radM:RadMenu ID="RadMenu1" runat="server">
        </radM:RadMenu>
        <br />
        <br />
        &nbsp;</div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <input id="Button1" type="button" value="Open" onclick="OpenItem( true );return false;"/><br />
        <input id="Button2" type="button" value="Close" onclick="OpenItem( false );return false;"/><br />
        <input id="Button3" type="button" value="Disable" onclick="EnableItem( false );return false;"/><br />
        <input id="Button4" type="button" value="Enable" onclick="EnableItem( true );return false;"/><br />
        <input id="Button5" type="button" value="Enumerate" onclick="EnumerateAllItems();return false;"/>
    </form>
</body>
</html>
