locked
Client-Side Control of RadMenu in Master Page RRS feed

  • Question

  • User39399457 posted

    hi guys,

     please help me out!

    I have a master page that contains a RadMenu:

    on Masterpage.master:

     <div id="menuDiv">      
        <telerik:RadMenu  ID="RadMenu1" runat="server" BorderColor="black">
        </telerik:RadMenu>
    </div>

     

    on Masterpage.master.cs there are a banch of menuitems like this:

        protected void BuildDisplayMenu()
        {
            RadMenuItem item1_3 = new RadMenuItem();
            item1_3.Text = "Display";
            item1_3.ToolTip = "Display Setting";
            
            item1_3.NavigateUrl = "~/traders/Preference/Display.aspx";
            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:

    				<tr><td>Show Display:</td><td>
    				<asp:RadioButtonList ID="si_enable_Display" runat="server" RepeatLayout="Flow" RepeatDirection="horizontal" AutoPostBack="true">
    					<asp:ListItem Text="Yes" Value="enable" onclick="javascript:DisplayStat(value);"></asp:ListItem>
    					<asp:ListItem Text="No" Selected="true" Value="disable" onclick="javascript:DisplayStat(value);"></asp:ListItem>
    				</asp:RadioButtonList></td></tr>


    
    
    I have tried numerous times, but still failed! 

    The DisplayStat() function I have tried this:

                <script type="text/javascript" language="javascript">
                    function DisplayStat(object)
                    {
                        var menuID = $find('<%=((RadMenu)Master.FindControl("RadMenu1")).ClientID %>');
                        var item = menuID.findItemByText("Display");
                        if(object=="enable"){
                         item.Enable();
                         }
                         else{
                            item.disable();
                         }
                    }
    
                </script>

     

    The 'menuID' is not functioning..by 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!!!


     

     

    Monday, September 27, 2010 9:48 AM

All replies

  • User1224194097 posted

    <asp:RadioButtonList ID="si_enable_Display" runat="server" RepeatLayout="Flow" 

    RepeatDirection="horizontal" AutoPostBack="true">


    why don't you do it on SelectedIndexChanged Event

    <asp:RadioButtonList ID="si_enable_Display" runat="server" 
        RepeatLayout="Flow" RepeatDirection="horizontal"AutoPostBack="true" 
        onselectedindexchanged="si_enable_Display_SelectedIndexChanged">
        <asp:ListItem Text="Yes" Value="true"></asp:ListItem>
        <asp:ListItem Text="No" Selected="true" Value="false"></asp:ListItem>
    </asp:RadioButtonList>
    protected void si_enable_Display_SelectedIndexChanged(object sender, EventArgs e)
    {
        RadMenu radMenu1 = (RadMenu)Master.FindControl("RadMenu1");
        RadMenuItem menuItem = new RadMenuItem();
        //
        //
        //Find Display item here
        //
        //
        if (menuItem != null)
            menuItem.Enabled = Boolean.Parse(si_enable_Display.SelectedValue);
    }

    Tuesday, September 28, 2010 12:59 PM