Keep current menu item selected

2 posts, 0 answers
  1. Frank
    Frank avatar
    1 posts
    Member since:
    Dec 2008

    Posted 11 Dec 2008 Link to this post

    Hi,

    Can anyone tell me if there is a simple solution to this problem?
    When I click a menu item (horizontal menu) or one of it's children, I must have the current menu item highlighted like when I hover over the item, but then fixed. If I click another item this item must get highlighted.

    How can this be done?

    Thanks in advance,
    Frank 
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Dec 2008 Link to this post

    Hello Frank,

    Check out the following code to get The required scenario.
    cs:
    protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e) 
        {         
            if(e.Item is RadMenuItem) 
            { 
                string strtxt = e.Item.Text;             
                e.Item.BackColor = System.Drawing.Color.Red; 
                foreach (RadMenuItem item in RadMenu1.Items) 
                { 
                    if (item.Text != strtxt) 
                        item.BackColor = System.Drawing.Color.Empty; 
                    foreach (RadMenuItem item2 in item.Items) 
                    { 
                        if (item2.Text != strtxt) 
                            item2.BackColor = System.Drawing.Color.Empty; 
                    } 
                }             
            }  
        }

    Thanks
    Princy.


Back to Top