RadMenu not closing anymore

2 posts, 0 answers
  1. JohnA
    JohnA avatar
    12 posts
    Member since:
    Jan 2006

    Posted 25 Nov 2016 Link to this post

    Hello,

    In the new version of UI for ASP.NET AJAX, v2016.3.1027,  the RadMenu no longer closes in Internet Explorer 11 when using the code below. When selecting "Action 2" under "Actions", the javascript code in the OnClientItemClicking handler would close the menu, but now the menu stays visible.  It had been working up to this point after several years, and still works in other browsers (Edge, Chrome).  Please Advise.

    Thank You!

     

    01.<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="RadMenuNotClosing.WebForm1" %>
    02.<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    03.<!DOCTYPE html>
    04. 
    06.<head runat="server">
    07.    <title></title>
    08.</head>
    09.<body>
    10.    <form id="form1" runat="server">
    11.        <telerik:RadScriptManager ID="rsm" runat="server">
    12. 
    13.        </telerik:RadScriptManager>
    14.    <div>
    15.        <telerik:RadMenu ID="rmTest"
    16.                runat="server"
    17.            OnClientItemClicking="MenuItemClicking"
    18.            CollapseAnimation-Duration="0"
    19.            ExpandAnimation-Duration="0"
    20.            CollapseAnimation-Type="None"
    21.            ExpanDelay="0"
    22.            CollapseDelay="0"
    23.            ClickToOpen="true"
    24.            >
    25.            <Items>
    26.                <telerik:RadMenuItem Text="File">
    27.                    <Items>
    28.                        <telerik:RadMenuItem Text="Exit">
    29.                        </telerik:RadMenuItem>
    30.                    </Items>
    31.                </telerik:RadMenuItem>
    32.                <telerik:RadMenuItem Text="Actions">
    33.                    <Items>
    34.                        <telerik:RadMenuItem Text="Action 1" Value="Action1" >
    35.                        </telerik:RadMenuItem>
    36.                        <telerik:RadMenuItem Text="Action 2" Value="Action2"  >
    37.                        </telerik:RadMenuItem>
    38.                    </Items>
    39.                </telerik:RadMenuItem>
    40.            </Items>
    41.        </telerik:RadMenu>
    42.        <script type="text/javascript">
    43.            function MenuItemClicking(sender,args)
    44.            {
    45.                var item = args.get_item();
    46.                var itemValue = item.get_value();
    47.                if (itemValue == "Action2")
    48.                {
    49.                    var txt = document.getElementById("txtText");
    50.                    txt.value = "Action 2 taken";
    51.                    args.set_cancel(true);
    52.                    sender.close();
    53.                    return;
    54.                }
    55.            }
    56.        </script>
    57.    </div>
    58.        <br />
    59.        <br />
    60.        <br />
    61.        <asp:TextBox ID="txtText" runat="server" Text="-" ClientIDMode="Static">
    62.        </asp:TextBox>
    63.    </form>
    64.</body>
    65.</html>
  2. Dimitar
    Admin
    Dimitar avatar
    298 posts

    Posted 29 Nov 2016 Link to this post

    Hello,

    You may overcome this issue by wrapping the sender.close() line in a setTimeout() function with a slight delay:

    setTimeout(function () { sender.close(); }, 10);

    Thus, the menu item will close again in all browsers.

    Best regards,
    Dimitar
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top