Hiding RadMenu item client side

2 posts, 0 answers
  1. Ron
    Ron avatar
    17 posts
    Member since:
    Jul 2011

    Posted 18 Sep 2012 Link to this post

    I am trying to hide a menu item from the client, but after the menu is hidden it reappears.
    What am I doing wrong?

    Here's the sample code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head runat="server">
        <title></title>
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
          function ClientClicked(sender, args) {
            var menu = $find("<%= treeMenu.ClientID %>");
      
            var items = menu.get_items();
            items.getItem(2).hide();
          }
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <telerik:RadSkinManager ID="RadSkinManager1" Runat="server" Skin="Simple">
        </telerik:RadSkinManager>
        <div>
    <telerik:RadMenu Runat="server" ID="treeMenu">
      <Items>
        <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem runat="server" Text="Root RadMenuItem2">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem runat="server" Text="Root RadMenuItem3">
        </telerik:RadMenuItem>
      </Items>
        </telerik:RadMenu><br />
        </telerik:RadMenu><br />
        <telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" 
          OnClientClicked="ClientClicked">
        </telerik:RadButton>
       
        </div>
        </form>
    </body>
    </html>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Sep 2012 Link to this post

    Hi Ron,

    I also observed the same behavior. Try setting AutoPostBack as false for the RadButton.
    aspx:
    <telerik:RadButton ID="RadButton1" AutoPostBack="false" runat="server" Text="RadButton"  OnClientClicked="ClientClicked"></telerik:RadButton>

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