RadMenu Sub Menus Expand onClick but not onMouseHover

2 posts, 0 answers
  1. Rajender
    Rajender avatar
    8 posts
    Member since:
    Apr 2013

    Posted 05 Nov 2013 Link to this post

    Hi,
    i need to expand sub menus onClick but not onMouserHover. i have tried it by adding a property ClickToOpen="True"  but while clicking on menu sub menus are opening, page is taking a postback and sub menus are closing again. Sub menus should be in open state but it is closing. Requesting to provide me some solution on this.

    Thanks and Regards
    A.Rajender
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2013 Link to this post

    Hi Rajender,

    If you have attached the OnItemClick server side event of the RadMenu, then postback happens on clicking the menu items and the RadMenu items remain closed. So if that is the case you can open the menu items by calling a script from the server side as shown in the following code.

    ASPX:

    <telerik:RadMenu ID="RadMenu1" runat="server" ClickToOpen="true" OnItemClick="RadMenu1_ItemClick">
        <Items>
            <telerik:RadMenuItem Text="Menu1" runat="server">
                <Items>
                    <telerik:RadMenuItem Text="submenu1" runat="server">
                        <Items>
                            <telerik:RadMenuItem Text="submenu1.2" runat="server">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="submenu1.3" runat="server">
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
            <telerik:RadMenuItem Text="Menu2" runat="server">
                <Items>
                    <telerik:RadMenuItem Text="submenu1.1" runat="server">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="submenu1.2" runat="server">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>

     C#:
    protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
    {
        if (e.Item.Items.Count > 0)
        {
            string menuItem = e.Item.Text;
            string script = "function f(){openMenu('" + menuItem + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        }
    }

    JavaScript:
    <script type="text/javascript">
        function openMenu(itemText) {
            $find("RadMenu1").findItemByText(itemText).open();
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top