Menu Question: How to change background for every other root item

V

va

I have a horizontal menu and at the toor leverl, I need to change every other
one's background color. Assume, I have the following menu:
"A" "B" "C" "D"

And I want B and D to be black background white text when first displayed.
I can see hwo to change all items through CSS but how do I change individual
menu items without changing all lt the same level?
 
K

Kelly Leahy

Well,

The short answer is, I don't think there's an easy way. However, here's
something you can do:

<DynamicItemTemplate>
<div style='width:100%;height:100%;background-color:<%#
Container.ItemIndex % 2 == 0 ? "Black" : "White" %>;color:<%#
Container.ItemIndex % 2 == 0 ? "White" : "Black" %>'><%# Eval("Text") %></div>
</DynamicItemTemplate>

This goes into your Menu control's innerXml (i.e. the stuff between the
beginning and end tags of the asp:Menu control).

You'll need a lot of tweaking for this to act as nice as the original menu
template. I'd try to infer the original template first, and then just add
this tweak to set the style in the DIVs.

Cheers,
Kelly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top