Related RadMenu

2 posts, 1 answers
  1. Joseph
    Joseph avatar
    21 posts
    Member since:
    Mar 2013

    Posted 05 Apr 2013 Link to this post

    Hi,

    There is a RadMenu on top of my page. Based on the selected menu, I want to populate another RadMenu. Please help.

    Thanks in advance
    Joseph.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Apr 2013 Link to this post

    Hi Joseph,

    Please have a look at the following sample code which works fine at my end.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadMenu1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="CategoryPanel" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick" Skin="Office2010Silver">
        <Items>
            <telerik:RadMenuItem Text="Laptop" />
            <telerik:RadMenuItem Text="PenDrive" />
            <telerik:RadMenuItem Text="Mobile" />
        </Items>
    </telerik:RadMenu>
    <br />
    <asp:Panel runat="server" ID="CategoryPanel">
        <h4>
        <br />
            <asp:Label runat="server" ID="CurrentCategory" /></h4>
        <telerik:RadMenu ID="RadMenu2" runat="server" Flow="Vertical" Visible="false" Skin="Office2010Silver">
        </telerik:RadMenu>
    </asp:Panel>

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            FilterMenu(RadMenu1.FindItemByText("Laptop"));
        }
    }
     
    protected void FilterMenu(RadMenuItem rootItem)
    {
        RadMenu2.Items.Clear();
     
        switch (rootItem.Text)
        {
            case "Laptop":
                RadMenu2.Items.Add(new RadMenuItem("Dell"));
                RadMenu2.Items.Add(new RadMenuItem("HP"));
                RadMenu2.Items.Add(new RadMenuItem("Lenovo"));
                RadMenu2.Items.Add(new RadMenuItem("Acer"));
                break;
            case "PenDrive":
                RadMenu2.Items.Add(new RadMenuItem("Transcend"));
                RadMenu2.Items.Add(new RadMenuItem("SanDisk"));
                RadMenu2.Items.Add(new RadMenuItem("Kingston"));
                RadMenu2.Items.Add(new RadMenuItem("HP"));
                break;
            case "Mobile":
                RadMenu2.Items.Add(new RadMenuItem("Samsung"));
                RadMenu2.Items.Add(new RadMenuItem("Nokia"));
                RadMenu2.Items.Add(new RadMenuItem("Sony"));
                RadMenu2.Items.Add(new RadMenuItem("HTC"));
                break;
        }
        RadMenu2.Items[0].Width = Unit.Pixel(168);
        RadMenu2.Visible = true;
        CurrentCategory.Text = rootItem.Text;
        rootItem.Selected = true;
    }
     
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
    {
        FilterMenu(e.Item);
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top