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

Setting the css-class for a menu-item based on the webpage url

1 Answer 65 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Lars Melkevik
Top achievements
Rank 1
Lars Melkevik asked on 24 Nov 2011, 03:13 PM
Is there a way I can set a css-class for a single menu-item based on the webpage url? (Maybe when the menu is generated?)
The menu is generated from a database.

Example:
If url = www.domain.com/page.aspx?id=1 then I would like menuitem "Menuitem1" to have a red font color. And if url = www.domain.com/page.aspx?id=2 then I would like menuitem "Menuitem2" to have a red font color.

Best regards,
Lars
 

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 28 Nov 2011, 12:11 PM
Hi Lars,

Using the OnClientLoad event of the RadMenu control you can get the page url as described in the following forum posts:
http://forums.digitalpoint.com/showthread.php?t=267256
http://stackoverflow.com/questions/2426958/get-page-url-using-javascript
http://stackoverflow.com/questions/1034621/get-current-url-with-javascript

Then you can implement the logic according to your scenario - find the appropriate menu item and use the set_cssClass("nameOfCssClass") property in order to set a css class and alter the appearance of the item.

All the best,
Kate
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Menu
Asked by
Lars Melkevik
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or