This is a migrated thread and some comments may be shown as answers.

Hiding RadMenu item client side

1 Answer 127 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 18 Sep 2012, 03:11 PM
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>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Sep 2012, 05:50 AM
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.
Tags
Menu
Asked by
Ron
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or