Jay
Jay

Reputation: 27464

how to apply a style to an asp.net menu when the item is selectable=false

I'm using the asp.net menu control. Depending on the user's privileges I set some items on the menu to selectable=false. So asp.net takes the link away, cool. But I'd like to make it obviously visually different, e.g. grayed out. i.e. I'd like to have a different CSS style for selectable=true items versus selectable=false items. Is there any way to do this? I don't see an option for it.

Upvotes: 0

Views: 605

Answers (1)

Seano666
Seano666

Reputation: 2238

Simply find the links that have no '#' href in css.

<style>
        .MenuExample a:not([href='#']) {
            background-color: red !important;
        }
    </style>    
<asp:Menu ID="Menu1" runat="server" StaticDisplayLevels="3" CssClass="MenuExample">
          <Items>
            <asp:MenuItem Text="File" Value="File">
              <asp:MenuItem Text="New" Value="New"></asp:MenuItem>
              <asp:MenuItem Text="Open" Value="Open" Selectable="false"></asp:MenuItem>
            </asp:MenuItem>
            <asp:MenuItem Text="Edit" Value="Edit">
              <asp:MenuItem Text="Copy" Value="Copy"></asp:MenuItem>
              <asp:MenuItem Text="Paste" Value="Paste"></asp:MenuItem>
            </asp:MenuItem>
            <asp:MenuItem Text="View" Value="View">
              <asp:MenuItem Text="Normal" Value="Normal"></asp:MenuItem>
              <asp:MenuItem Text="Preview" Value="Preview"></asp:MenuItem>
            </asp:MenuItem>
          </Items>
        </asp:Menu>]

Upvotes: 1

Related Questions