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

RadMenu, Masterpage and ContentPlaceHolder Page

5 Answers 212 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Patrick Williams
Top achievements
Rank 1
Patrick Williams asked on 17 May 2010, 05:10 PM
Hi All,

Could someone help me in understanding how to determine which radmenu item was clicked/selected from a page using master page. I'm trying to get the selectedvalue of that menu item to save to a database and also to determine  which user control to populate on the page.

That is, my radmenu is on my master page and from any page in the application i would like to determine which radmenu item were selected.

Thanks in advance for your response.
Patrick.

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 19 May 2010, 11:44 AM
Hello Patrick,

You can use SelectedItem property of the menu, because you open a new page and there's a different instance of the menu from the previous page.

I suggest you use the following approach to find the clicked item and select it:

RadMenu menu = (RadMenu)Master.FindControl("RadMenu1");
RadMenuItem currentItem = menu.FindItemByUrl(Request.Url.PathAndQuery);
if (currentItem != null)
   currentItem.Selected = true;


Best regards,
Yana
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.
0
Patrick Williams
Top achievements
Rank 1
answered on 27 May 2010, 07:54 PM
Hi Yana,

The method suggested I cannot use, because some of the page called by navigationUrl will be the same the only difference on this page is that I want to get the selectedValue to determine which User Control to load on that page.

I know i can pass the value that i want with a query string through the navigationUrl but i dont want this value to be visible to ensure adequate  security. I tried also using javascript to get the selectedValue but this was not successful as well. The function "get_selectedItem()" seems to be not working, it does not give me any result.
0
Yana
Telerik team
answered on 02 Jun 2010, 10:51 AM
Hello Patrick,

The other option is to save the value of the selected item in a session variable and after the postback get it from there.


Best wishes,
Yana
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.
0
Ravi
Top achievements
Rank 1
answered on 10 Mar 2015, 11:29 AM
Hi Yana,

Can you please Let me know what is Master in
RadMenu menu = (RadMenu)Master.FindControl("RadMenu1"); Its throwing error for me
0
Boyan Dimitrov
Telerik team
answered on 13 Mar 2015, 08:17 AM
Hello,

Master gets a reference to the Master page object. If you are not using a master page in your web site/application the Master will return null. In case calling the FindControl method will throw an error since the object is null. 

Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Menu
Asked by
Patrick Williams
Top achievements
Rank 1
Answers by
Yana
Telerik team
Patrick Williams
Top achievements
Rank 1
Ravi
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or