• 0

asp:menu


Question

I'm having a problem with selected item on asp:menu. All the CSS menu styles work fine except selected page (div.menu ul li a:active).

staticselectedstyle works but that is pretty limited and doesn't give the options I would like to have for selected item on the menu so I would need to get the style for selected item from CSS or is this not possible at all with asp:menu?

(Script)

    void NavigationMenu_MenuItemDataBound(Object sender, MenuEventArgs e)
    {
        MenuItem item = e.Item;

        if (item.Text == "Home")
        {
            item.Selected = true;
        }
    }

(ASP Menu)

<asp:Menu ID="NavigationMenu" StaticDisplayLevels="2" StaticSubMenuIndent="10" CssClass="menu"
                    Orientation="Horizontal" DataSourceID="MenuSource" OnMenuItemDataBound="NavigationMenu_MenuItemDataBound"
                    runat="server">
                </asp:Menu>
                <asp:SiteMapDataSource ID="MenuSource" runat="server" />

(CSS)

div.menu ul li a, div.menu ul li a:visited
{
    height: 21px;
    background-color: #f8f7ef;
    color: #6f5a44;
    display: block;
    line-height: 1.35em;
    padding: 0px 10px;
    text-decoration: none;
    white-space: nowrap;
    border-top: 1px solid #f8f7ef;
    border-bottom: 1px solid #f2f2f2;
}

div.menu ul li a:hover
{
    height: 21px;
    background-color: #f8f7ef;
    border-top: 1px solid #f8f7ef;
    border-bottom: 1px solid #fca822;
    color: #000000;
    text-decoration: none;
}

div.menu ul li a:active
{
    height: 21px;
    background-color: #f5f5f5;
    border-top: 1px solid #f8f7ef;
    border-bottom: 1px solid #fca822;
    color: #000000;
    text-decoration: none;
}

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.