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

Radmenu selectedvalue in nested master page

3 Answers 110 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 2
Joseph asked on 07 Oct 2010, 11:46 PM
Hi,

I have a site.master page which contians a radmenu. I have another nested master page nested from site.master called submaster . I was trying to get the menu selected value in the pageload event of the submaster.

This code is in the submaster  page_load event

RadMenu cMenu = (RadMenu)Master.FindControl("Radmenu1");

 

string cItem = cMenu.SelectedValue;

Here I am getting cItem as null. I have populated the Text and Value properties of every menu item in the site.master page. Is the syntax I am using correct? Any help is appreciated.

I have a default page created from the submaster which displays the contents.
I tried to put the same code in the default.aspx page also, but I am not getting the selected value.

Thanks
JK

 

 

3 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 13 Oct 2010, 11:38 AM
Hi Joseph,

I've tested your case and everything works fine for me. Please make sure that "Radmenu1" in this syntax:

RadMenu cMenu = (RadMenu)Master.FindControl("Radmenu1");

 matches the ID of the control in the Parent.master.

I've attached my project in a .zip file.

Hope this helps.

Greetings,
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
0
Joseph
Top achievements
Rank 2
answered on 22 Oct 2010, 11:30 PM
Thanks Veronica for the response. But my issue is not solved even by your code. In your code you hardcoded the one of the menu item as selected="True" which will return to the child master file. But that is not the case alsways. Whenever we click any menu item that items value must be returned in the child master file and I need to do some process in the child master file based on that value.

Below is the code from your sample.

in parent.master - you hardcoded the Selected="true" for Child RadMenuitem 2.
            <Items>
                        <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2" Selected="true">
                        </telerik:RadMenuItem>
                    </Items>

If you dont hardcode Selected="true" in the menu defenition you are going to get null value for cItem the in the child master file (that is what I am getting).

        RadMenu cMenu = (RadMenu)Master.FindControl("RadMenu1");
        string cItem = cMenu.SelectedValue;


Can you please test and validate this. Also please let me know how can I get this value in the child master file. May be I am thinking wrong and approching this in the wrong way. Any help is appreciated.


0
Veronica
Telerik team
answered on 03 Nov 2010, 09:39 AM
Hello Joseph,

Please accept my apologies for the late reply.

Yes, you are right that with setting Selected="true" on any of the RadMenu items in the markup - after postback you will get one and the same SelectedValue in clItem. However if I remove Selected="true" and try to get SelectedValue in the Child.Master I have no problem with it. Please take a look at the edited .zip file which I just attached.
 
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
Joseph
Top achievements
Rank 2
Answers by
Veronica
Telerik team
Joseph
Top achievements
Rank 2
Share this question
or