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

Client-Side Control of RadMenu in Master Page

1 Answer 109 Views
Menu
This is a migrated thread and some comments may be shown as answers.
jialiang_liu
Top achievements
Rank 1
jialiang_liu asked on 27 Sep 2010, 03:23 PM

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>  
04.lt;/div>

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

 
Then,
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>  
05.</asp:RadioButtonList></td></tr>
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.    }  
13. 
14.</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!!!

1 Answer, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 28 Sep 2010, 04:31 PM
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
Tags
Menu
Asked by
jialiang_liu
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Share this question
or