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

Forums / Developing with Sitefinity / RadMenuItem CssClass

RadMenuItem CssClass

4 posts, 0 answered
  1. Levi Burton
    Levi Burton avatar
    11 posts
    Registered:
    16 Apr 2010
    29 Jul 2010
    Link to this post
    Hello,

    I need to set a CssClass on a RadMenuItem when generating my navigation using the SiteMenu control.  I currently do this in the RadMenu1_ItemDataBound event.

    The problem I'm having is the CssClass property of the RadMenuItem is not the html element I want to class.  For example, this is the generated output:
    <li class="rmItem rmLast"><a class="rmLink accessory" href="Corn/Acceleron.aspx" style="width: 200px;"><span class="rmText ">Acceleron</span></a></li>

    My CssClass is "accessory".  I would like to apply this class to the <li> element rather than the <a> element.  Is this possible?

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2010
    Link to this post
    Hi Levi Burton,

    You can do this with jQuery. Once you set the accessory class in the ItemDataBound event you can then use jQuery to get all <a> elements with accessory class and set the same class to their parent items. You can find more information on the functions you need to use here:
    Element Selector (“element”)
    Class Selector (“.class”)
    :parent Selector

    Regards,
    Radoslav Georgiev
    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. Levi Burton
    Levi Burton avatar
    11 posts
    Registered:
    16 Apr 2010
    10 Aug 2010
    Link to this post
    This works, but there is a small delay caused by changing the css classes.  I am changing my classes in the $(document).ready event.  Is there any way to remove the delay?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    11 Aug 2010
    Link to this post
    Hi Levi Burton,

    The delay is because the document.ready event is when the whole page has finished loading all html and java script. You can perform the same logic in OnClientLoad event of the menu - this will execute the code when the menu is loaded and initialized on the client, rather than when the whole page is loaded.

    Regards,
    Radoslav Georgiev
    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
Register for webinar
4 posts, 0 answered