1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Selected Item in site menu control

Selected Item in site menu control

2 posts, 0 answered
  1. Chris Wilper
    Chris Wilper avatar
    13 posts
    Registered:
    01 Sep 2009
    04 Nov 2009
    Link to this post
    How do I set the selected navigation item.  I would like to change the style on the menu item when it is clicked by the user.  I tried useing selecteditem, but that doesn't work.  Any ideas?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Nov 2009
    Link to this post
    Hi Chris Wilper,

    You can subscribe for RadMenu's ItemDataBound event and add the following logic

    CmsSiteMapNode currentNode = SiteMap.CurrentNode as CmsSiteMapNode;
    RadMenuItem menuItem= RadMenu1.FindItemByText(currentNode.Title);
    if (menuItem!= null)
    {
        menuItem.CssClass = selectedItemCssClass;
     
    }

    You could expose a public property to setting the css

    [Browsable(true)]
        [Category("Appearance")]
        public string SelectedItemCssClass
        {
            get
            {
                return this.selectedItemCssClass;
            }
            set
            {
                this.selectedItemCssClass = value;
            }
        }
     
    private string selectedItemCssClass = "selectedItem";

    In your style sheet you should have a class called selectedItem that will be applied to the selected item.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered