We help IT Professionals succeed at work.
Get Started

How to apply a css stylesheet to an asp menu

Dovberman
Dovberman asked
on
3,128 Views
Last Modified: 2015-04-15
I used the following example in an attempt to apply a css style sheet to a menu.
http://jobinjohn.blogspot.com/2011/06/styling-aspnet-menu-control-with-css.html

This is my aspx code snippet:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 <asp:Menu ID="Menu1" CssClass="MYMenuClass"
        Orientation="Horizontal"
        MaximumDynamicDisplayLevels="3"
        runat="server">


        <Items>
            <asp:MenuItem NavigateUrl="#" Text="New Item" Value="New Item">
                <asp:MenuItem NavigateUrl="#" Text="New Item" Value="New Item"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="New Item New Item" Value="New Item"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="New Item" Value="New Item"></asp:MenuItem>
            </asp:MenuItem>

This is my css code snippet:

.MYMenuClass {
    color: Green;
    background-color: #00FFFF;
}

.MYMenuClass ul {
    background: #00FFFF;
}

.MYMenuClass ul li {
    background: #00FFFF none no-repeat;
    text-align: center; /* set width if needed.*/
    width: 200px;
}

.MYMenuClass ul li a
{
    color: black;
    padding: 4px 2px 4px;
    padding-left:8px !important;
    border:1px solid #648ABD;
    border-bottom: 0
   
}

.MYMenuClass ul li a:hover
{
    background-image: none;
}

.MYMenuClass ul li a:hover
{
    color: White;
}

Nothing in the css file is applied to the menu.

What am I missing?

Thanks,
Comment
Watch Question
Developer
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
Unlock 3 Answers and 14 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE