Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:26:30+00:00 2026-06-14T10:26:30+00:00

I am having problems configuring my asp:Menu. When I use any css, the menu

  • 0

I am having problems configuring my asp:Menu. When I use any css, the menu items don’t get selected anymore. I’ve tried 3 versions, and each has it’s drawback.

This one work the best for css, but the selected item doesn’t get selected.

<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" Orientation="Horizontal" StaticEnableDefaultPopOutImage="false"DataSourceID="smdsMaster" StaticDisplayLevels="2">
    <LevelMenuItemStyles>
        <asp:MenuItemStyle ForeColor="White"/>
        <asp:MenuItemStyle ForeColor="White" />
    </LevelMenuItemStyles>
    <Items>
        <asp:MenuItem Text="Menu 1" NavigateUrl="~/Menu1.aspx" />
        <asp:MenuItem Text="Menu 2"  NavigateUrl="~/Menu2.aspx" >
            <asp:MenuItem Text="Submenu 2" NavigateUrl="~/Submenu2.aspx" />
        </asp:MenuItem>
    <asp:MenuItem Text="Menu 3" NavigateUrl="~/Menu3.aspx" />
    </Items>
</asp:Menu>

This one shows selected, but I can’t use images as backgound for the menuitems. If I add css in it, the selection won’t show anymore. And the sub-item is always present.

<asp:Menu ID="NavigationMenu" runat="server" DataSourceID="smdsMaster" DynamicHorizontalOffset="0" StaticEnableDefaultPopOutImage="false"
 Orientation="Horizontal" StaticDisplayLevels="2" StaticSubMenuIndent="0px"  MaximumDynamicDisplayLevels="2" OnMenuItemDataBound="Menu1_MenuItemDataBound"
 ForeColor="White" BackColor="#EE7B00" StaticItemFormatString="<p align=center> {0}" DynamicItemFormatString="<p align=center> {0}">
    <StaticMenuItemStyle BackColor="#EE7B00" Width="110px" Height="31px" HorizontalPadding="0px" VerticalPadding="0px" />
    <StaticHoverStyle BackColor="#CCCC00" />
    <StaticSelectedStyle BackColor="#CCCC00" />
    <DynamicMenuItemStyle HorizontalPadding="0px" VerticalPadding="0px" Width="110px" Height="31px" />
    <DynamicHoverStyle BackColor="#CCCC00" />
    <DynamicMenuStyle BackColor="#EE7B00" />
    <DynamicSelectedStyle BackColor="#CCCC00" />
</asp:Menu>

How can I have both: images as background for my menuitems, with text over it, AND show witch item is selected.

Thanks.


UPDATE

Here is the CSS that goes with it:

.page .header_menu .menu
{
    !margin: 0px;
    padding: 0;
    list-style: none;
    background: none;
    z-index: 3;
}

.page .header_menu .menu li
{
    padding: 0;
    margin: 0;
    height: 31px;
    list-style: none;
    background-repeat: no-repeat;
    float: left;
    width: 110px;
}

.page .header_menu .menu li a
{
    display: block;
    text-decoration: none;
    text-align: center;
    height: 31px;
    width: 110px;
    padding-top: 5px;
    background-repeat: no-repeat;
    background-image: url(../Assets/btn-back-normal.gif);
    color: white;
    margin-top: -1px; /*Chrome = -16, IE = 0*/
    z-index: 1;
}

.page .header_menu .menu li a:hover
{
    background-image: url(../Assets/btn-back-over.gif);
    color: white;
    margin-top: -1px; /*Chrome = -16, IE = 0*/
    z-index: 1;
    width: 110px;
}

.page .header_menu .menu li a:active, .page .header_menu .menu li a:selected
{
    background-image: url(../Assets/btn-back-selected.gif);
    color: white;
    margin-top: -1px;
    z-index: 1;
    width: 110px;
}

.page .header_menu .menu:after
{
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
    z-index: 1;
    width: 110px;
}

I also tried to set these, but only the first item stays selected, no matter wicht one actually is selected

<style type="text/css">
#NavigationMenu a{padding-right: 0px; padding-left: 0px; padding-top: 5px; height: 26px; background-color: #EE7B00;}
#NavigationMenu a.static{ padding-right: 0px; padding-left: 0px; padding-top: 5px; height: 26px; background-color: #EE7B00;}
#NavigationMenu a.static.selected{padding-right: 0px; padding-left: 0px; padding-top: 5px; height: 26px; background-color: #cccc00;}
#NavigationMenu a.dynamic{padding-right: 0px; padding-left: 0px; padding-top: 5px; height: 26px; background-color: #EE7B00;}
#NavigationMenu a.dynamic.selected{padding-right: 0px; padding-left: 0px; padding-top: 5px; height: 26px; background-color: #cccc00;}
</style>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:26:31+00:00Added an answer on June 14, 2026 at 10:26 am

    If you run your .aspx page and examine the source you will notice that the menu item <a> (hyperlink) tag has a selected class called a.selected.static you can implement your own version of this in your code and override it by applying !important to the CSS class.

    The sample below displays a simple menu with image menu items and highlights the image with a red border when selected:

    <head runat="server">
        <title>Menu</title>
        <style type="text/css">
            a.selected.static
            {
                border:2px solid red !important;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
            <Items>
                <asp:MenuItem ImageUrl="~/Images/1.jpg" Text="Item 1" />
                <asp:MenuItem ImageUrl="~/Images/2.jpg" Text="Item 2" />
                <asp:MenuItem ImageUrl="~/Images/3.jpg" Text="Item 3" />
            </Items>
        </asp:Menu>
        </form>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting using the Log4Net library and having problems configuring it. I don't
Having problems with assigning a specific id to a varied list of items selected
I am having problems configuring JRuby to work properly with OpenSSL. Googling has revealed
This is my first time using nginx and I'm having some problems configuring an
Im having problems with trying to set a select option to selected, it does
I am having problems configuring a many to many relationship to a model itself.
I am having ongoing problems configuring my Spring Controller to map to specific URLs,
I am having a problem configuring my web-app to use Spring security on Virgo
Having problems with my ASP.NET MVC2 project. I'm using Fluent NHibernate as ORM, and
I'm having problems trying to get a Spring 3.1 Framework webapp using the Servlet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.