Set style of root radmenuitem when child item is selected. in UI for ASP.NET AJAX Menu - Telerik Forums
Description: Join a community of over 2.6m developers to have your questions answered on Set style of root radmenuitem when child item is selected. of UI for ASP.NET AJAX Menu. New here? Start with our free trials.

# Set style of root radmenuitem when child item is selected.

Cancel

- Telerik UI for ASP.NET AJAX

Feed for this thread
3 posts, 0 answers

1. ##### Big Daftie

   7 posts
   Member since:
   Jun 2008

   Posted 24 Sep 2010 Link to this post

   Hi all,
   I'm attempting to set the style of a root menuitem to it's focussed state when an item in its submenu has been selected. I'm doing this in a master page, code as follows:
   `Private Sub sitemenu_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles sitemenu.ItemCreated`
   `` `Dim item As RadMenuItem = sitemenu.FindItemByUrl(Request.Url.PathAndQuery)`
   `` `If item IsNot Nothing Then`
   `` `item.CssClass = "focused"`
   `` `End If`
   `` `End Sub`
   This works great, and the root items show the focussed state when clicking between them. However when i click on a child item, the root menu item does not have the focused class added to it. Any pointers?

3. ##### Peter

   Admin
   6637 posts

   Posted 28 Sep 2010 Link to this post

   Hello Big Daftie,
   Please, see the Show Path And BreadCrumb demo. Basically, you need to call the HighlightPath() method of the current item.
   All the best,
   Peter
   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

5. ##### Big Daftie

   7 posts
   Member since:
   Jun 2008

   Posted 28 Sep 2010 Link to this post

   Hi there Peter,
   thanks for you reply. I actually sorted this myself - I was using loadcontentfromfile(), which did not databind the xml so could not use the itemdatabound() handler.
   I've now moved the code to itemdatabound, and modified it to the following (in the unlikely event it's of use to anyone else):
   `Dim` `item` `As` `RadMenuItem = sitemenu.FindItemByUrl(Request.Url.PathAndQuery)`
   `If` `item IsNot` `Nothing` `Then`
   `` `If` `item.Level > 0` `Then` `'menu will only ever be one level deep`
   `` `Dim` `rootitem` `As` `RadMenuItem = item.Parent`
   `` `rootitem.CssClass =` `"focused"`
   `` `End` `If`
   `` `item.CssClass =` `"focused"`
   `End` `If`
   This seems to work fine - however I'm looking at your breadcrumb demo just now :)
   Many thanks!

Back to Top

#

Close