Radmenu selectedvalue in nested master page

4 posts, 0 answers
  1. Joseph
    Joseph avatar
    7 posts
    Member since:
    May 2008

    Posted 07 Oct 2010 Link to this post

    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

     

     

  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 13 Oct 2010 Link to this post

    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
  3. Joseph
    Joseph avatar
    7 posts
    Member since:
    May 2008

    Posted 22 Oct 2010 Link to this post

    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.


  4. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 03 Nov 2010 Link to this post

    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
Back to Top