asp menu

hey guys i need to loop through my asp menu and make the items background alternate

e.g

red / green / red / green

i need to do it in c# code
JCWEBHOSTAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

APoPhySptCommented:
Do yuo want to change the entire menu color at once or have each option have a different color?
0
JCWEBHOSTAuthor Commented:
just each menu item like

home = red
services = green
products = red
0
APoPhySptCommented:
Hi.. as far as I know using '<asp:Menu' it cannot be done... perhaps you should try considering writing your own menu using just html tags with which you can have a lot more control over what's going on.

Take a look at the following tutorial on how to make a simple menu using <ul> & <li>:
http://jamesowers.co.uk/css-tutorials/50/horizontal-css-list-menu/

0
APoPhySptCommented:
but if you really want to change the Background color through C# code, using <ul> <li> you can do this:

Css File:
 
.navMenu ul
{
    list-style: none;
    padding: 0;
    margin: 0;
    vertical-align:middle;
    text-align:center;
} 

.navMenu ul li
{
    height:25px;
    width:75px;
    vertical-align:middle;
}

.Red
{
    background-color: Red;
}

.Green
{
    background-color:Green;
}

Open in new window


Html Code ( goes into the *.aspx ):
 
<div class="navMenu" runat="server">
        <ul runat="server">
            <li runat="server" id="li1"><a href="#">Services</a></li>
            <li runat="server" id="li2"><a href="#">About us</a></li>
            <li runat="server" id="li3"><a href="#">Contact us</a></li>
        </ul>
    </div>

Open in new window


The code itself to change colors ( *.aspx.cs ):
 
li1.Attributes.Remove("class");
    li1.Attributes.Add("class", "Red");

    li2.Attributes.Remove("class");
    li2.Attributes.Add("class", "Green");

    li3.Attributes.Remove("class");
    li3.Attributes.Add("class", "Red");

Open in new window


perhaps not as pretty but should do the job

cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.