CSS workaround: html .RadMenu_Context .rmVertical .rmItem { clear: both; }
Basically, I would like to be able to set a default state for the menu (which menu is open and which menu item has focus) in code behind (like the Page Load event). The menu would start off showing the designated menu as open and the designated menu item would have focus but the user would still be able to hover over other menus to open them (the default open menu would then collapse). If the user ends up moving the mouse off the menu without clicking anything, the menu would then automatically revert to the default state set in Page Load. Currently, the only way to implement this functionality is to use hidden fields to store the open menu/focused menu item info (on Page Load) and then capture a bunch of JavaScript client events to setup the default menu state, collapse the menu when a different menu is hovered over and reset the menu to the default state when the mouse moves away without clicking. It works but it's a lot of client code and occasionally the JavaScript events don't fire correctly (or in the correct sequence) and the menu won't reset properly or maybe the sub menus will overdraw each other. It's a lot of work for something that I think should be built into the core RadMenu control. I'm also concerned about using so much JavaScript because I've been developing web apps for 15 years (using Telerik for 10 years) and every few years all my JavaScript code breaks (due to browser changes) and has to be rewritten. I'd much rather just set the relevant properties in code behind and let you guys worry about updating the client code. It would be great to just set the default state in code behind and have the menu reset to that state when it loses focus. You could also have a reset timeout so that the menu will reset after the mouse is off the menu for a set number of seconds. A quick Google search shows that people have been asking for an easy way to implement this for years.
After clicking the item, the custom class is removed (the color of the item text is changed) <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <style> .TopToolbarAlert, .TopToolbarAlert:link, .TopToolbarAlert:visited, .TopToolbarAlert:hover, .TopToolbarAlert:focus, .TopToolbarAlert:active { /*background-color: red;*/ color: red !important; } </style> </head> <body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <div> <telerik:RadMenu runat="server" ID="toolBarMenu"> <Items> <telerik:RadMenuItem ID="toolbarAlerts" runat="server" Text="Alerts" /> </Items> </telerik:RadMenu> </div> </form> </body> <script type="text/javascript"> $telerik.$(document).ready(function () { $telerik.$("#toolbarAlerts").addClass("TopToolbarAlert"); }); </script> </html>
Workaround: Set ClickToOpen = true in the control markup or if you want to set it only for the problematic browsers, use the following server-side code: protected void Page_Load(object sender, EventArgs e) { string userAgent = Request.UserAgent; string searchPattern = "ARM(?i)|Touch(?i)"; if (System.Text.RegularExpressions.Regex.IsMatch(userAgent, searchPattern)) { RadContextMenu1.ClickToOpen = true; } }