Changing the background image of Menu programatically

4 posts, 0 answers
  1. Lloyd Phillips
    Lloyd  Phillips avatar
    29 posts
    Member since:
    Dec 2004

    Posted 10 Jul 2008 Link to this post

    I'm building up the menu and our designers have created a background that needs to be visible when the user had clicked into that section. Our menu is blue with a yellow div panel below so when they are 'in' a particular section the menu item should go yellow to look like it flows into the panel below (a bit like a cut out). Say for example my menu has 2 root items called Section 1 and Section 2. If the user selects either item or any child items they will get transfered to the relevant page. When that page loads I need to change the background of the selected section to the yellow background. My menu structure is currently stored in an XML file, is it possible for me to do this? I'm thinking I can determine which section they are in by creating folders that match the Section names and then reading the url and then somehow matching the rootgroup names to the folder they are in before changing the css style but I don't know how or if it is possible? Is there some kind of OnItemDatabound or something or is there a better way?

    Can anyone help?

  2. Yana
    Yana avatar
    5043 posts

    Posted 10 Jul 2008 Link to this post

    Hello Lloyd Phillips,

    Thank you for contacting us.

    You can determine which RadMenuItem the user selected with the code snippet below:

    RadMenuItem item1 = RadMenu1.FindItemByUrl(Request.Url.LocalPath); 

    then you need to find its parent RadMenuItem and set a new cssClass property to it:

    int level = item1.Level;  
    while(level > 0)  
        item1 = (RadMenuItem) item1.Parent;  
        level = level - 1;  
    item1.CssClass = "selectedItem"

    Please check out the attached file for a reference.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 03 Aug 2008 Link to this post


    I want to set the backcolor and forecolor of all the child items programattically.
    I have 5 levels. When i set the back color programmatically, only level1's backcolor is changed. but not all the child items.
    Please help.


  4. Yana
    Yana avatar
    5043 posts

    Posted 04 Aug 2008 Link to this post

    Hello Sujith,

    I prepared a small demo project which shows how to set cssClass property to all child items of RadMenu. Please download it and give it a try.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top