This is a migrated thread and some comments may be shown as answers.

Changing the background image of Menu programatically

3 Answers 97 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Lloyd Phillips
Top achievements
Rank 1
Lloyd Phillips asked on 10 Jul 2008, 06:05 AM
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?

Lloyd

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 10 Jul 2008, 01:19 PM
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.

Regards,
Yana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
VS
Top achievements
Rank 1
answered on 04 Aug 2008, 04:21 AM
Hi,

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.

Regards

Sujith
0
Yana
Telerik team
answered on 04 Aug 2008, 04:15 PM
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.

Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Lloyd Phillips
Top achievements
Rank 1
Answers by
Yana
Telerik team
VS
Top achievements
Rank 1
Share this question
or