Client-Side Control of RadMenu in Master Page

2 posts, 0 answers
  1. jialiang_liu
    jialiang_liu avatar
    28 posts
    Member since:
    Jul 2006

    Posted 27 Sep 2010 Link to this post

    hi guys,

     please help me out!

    I have a master page that contains a RadMenu:

    on Masterpage.master:

    01.<div id="menuDiv">        
    02.   <telerik:RadMenu  ID="RadMenu1" runat="server" BorderColor="black">  
    03.   </telerik:RadMenu>;/div>

    on Masterpage.master.cs there are a banch of menuitems like this:
    01.protected void BuildDisplayMenu()  
    03.    RadMenuItem item1_3 = new RadMenuItem();  
    04.    item1_3.Text = "Display";  
    05.    item1_3.ToolTip = "Display Setting";  
    07.    item1_3.NavigateUrl = "~/traders/Preference/Display.aspx";  
    08.    RadMenu1.Items.Add(item1_3);  

    I have a content page called Preference.aspx, which has an Radio functioning the show or hide
    of the "Display" item clicked by clients:

    01.<tr><td>Show Display:</td><td>  
    02.<asp:RadioButtonList ID="si_enable_Display" runat="server" RepeatLayout="Flow" RepeatDirection="horizontal" AutoPostBack="true">  
    03.    <asp:ListItem Text="Yes" Value="enable" onclick="javascript:DisplayStat(value);"></asp:ListItem>  
    04.    <asp:ListItem Text="No" Selected="true" Value="disable" onclick="javascript:DisplayStat(value);"></asp:ListItem>  
    I have tried numerous times, but still failed! 
    The DisplayStat() function I have tried this:
    01.<script type="text/javascript" language="javascript">  
    02.    function DisplayStat(object)  
    03.    {  
    04.        var menuID = $find('<%=((RadMenu)Master.FindControl("RadMenu1")).ClientID %>');  
    05.        var item = menuID.findItemByText("Display");  
    06.        if(object=="enable"){  
    07.         item.Enable();  
    08.         }  
    09.         else{  
    10.            item.disable();  
    11.         }  
    12.    }  
    The 'menuID' is not some reason. I have also tried
    var menuID = document.getElementById('<%=((RadMenu)Master.FindControl("RadMenu1")).ClientID %>');

    And the problem still exists.

    Please Help me out !!!thanks A lot!!!

  2. Veronica
    Veronica avatar
    1213 posts

    Posted 28 Sep 2010 Link to this post

    Hello jialiang_liu,

    Thank you for the detailed explanation and code.

    I created a sample project to test your case. You'll have to set the AutoPostBack to "false" to be able to execute the DisplayStat() javascript function. In my project the item is successfuly disabled and enabled.

    Please take a look a the attached .zip file and let me know if this helps.

    All the best,
    Veronica Milcheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top