Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dynamic menu that an admin can edit it it is declared in a single page that redirect itself every time a menu item is clicked and change the query string. how could i change the css style of such a menu note that if a sub menu clicked the parent one should be set as current thanks
Posted

1 solution

Create 2 CSS classes say 'menuselected' and 'menunotselected'. Style the first one in the way you want selected menu to be shown and the other one for non selected menu.
When the user selects a menu, change it's css class to 'menuseleted' and all other menu will have class 'menunotselected' by default.

Hope that helps!
 
Share this answer
 
v2
Comments
[no name] 8-Aug-13 4:16am    
all the menu links redirect the same page but change the query string ID
Ankur\m/ 8-Aug-13 4:46am    
Let it be the same page. If the elements have different CSS class, the styles for them will be different.
[no name] 8-Aug-13 5:02am    
i know but all the menu calls the page index.aspx?parm=.... where the query string differs on every menu item so i need a javascript thet tell me the link where it is and give the parent menu a current css style. thanks
Ankur\m/ 8-Aug-13 5:23am    
Do you have ASP.NET menu control? As soon as you click, it must be posting back, right? If the control is accessible on server you can assign a CSS to it there
About the JavaScript part, it could be useful only when you wouldn't have posted back the page to server. Once the page is posted back the retrieved value using JavaScript is gone.
I am not very sure about how you are doing it.
[no name] 8-Aug-13 5:35am    
the menu is dynamic it is viewed in a <ul> that has jquery for hiding and viewing the subs the items of the menu is taken from a datalist that read them from the database so i didnt use the asp menu since the i have a template i should use

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900