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

Discussion in 'ASP .Net Web Controls' started by va, May 3, 2006.

  1. va

    va Guest

    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?
     
    va, May 3, 2006
    #1
    1. Advertising

  2. va

    Kelly Leahy Guest

    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

    "va" wrote:

    > 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?
     
    Kelly Leahy, May 4, 2006
    #2
    1. Advertising

  3. va

    va Guest

    RE: Menu Question: How to change background for every other root i

    Wow! Pretty brilliant. Thank you.
     
    va, May 4, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mike
    Replies:
    2
    Views:
    607
  2. Daves
    Replies:
    2
    Views:
    3,096
    Daves
    Apr 22, 2006
  3. QUASAR
    Replies:
    6
    Views:
    435
    QUASAR
    Jan 17, 2004
  4. Replies:
    0
    Views:
    313
  5. IntraRELY
    Replies:
    0
    Views:
    512
    IntraRELY
    Jun 9, 2007
Loading...

Share This Page