07-23-2023, 08:35 AM
I'm in the process of styling an asp.net menu and I'm trying to understand the meaning of the StaticSelectedStyle-CssClass and StaticHoverStyle-CssClass parameters.
My understanding is that the styles defined with these parameters are applied as CSS classes to the relevant elements, whenever needed. So I created my menu as follows:
<asp:Menu ID="NavigationMenu" DataSourceID="NavigationSiteMapDataSource"
StaticMenuStyle-CssClass="StaticMenuStyle"
StaticMenuItemStyle-CssClass="StaticMenuItemStyle"
StaticSelectedStyle-CssClass="StaticSelectedStyle"
StaticHoverStyle-CssClass="StaticHoverStyle"
Orientation="Horizontal"
MaximumDynamicDisplayLevels="0"
runat="server">
</asp:Menu>
It works for StaticMenuStyle-CssClass and StaticMenuStyle-CssClass (the classes are applied to the relevant elements), but StaticSelectedStyle-CssClass and StaticHoverStyle-CssClass are not applied, regardless of the selected or hover status of an element.
What am I supposed to do to make this work?
Thanks.
EDIT: Sorry I should have mentioned that this is .NET 4. Here is the generated HTML:
<div id="NavigationMenu">
<ul class="level1 StaticMenuStyle">
<li><a class="level1 StaticMenuItemStyle selected" href="/Link.aspx">Link</a></li>
</ul>
</div>
So as you can see, StaticMenuStyle and StaticMenuItemStyle are applied, but not StaticSelectedStyle-CssClass or StaticHoverStyle-CssClass. Not sure why. I know I can use selected but isn't the expected behavior that StaticSelectedStyle-CssClass be applied??? By using selected I make assumptions as to what .NET does behind the scenes and that's not right.
My understanding is that the styles defined with these parameters are applied as CSS classes to the relevant elements, whenever needed. So I created my menu as follows:
<asp:Menu ID="NavigationMenu" DataSourceID="NavigationSiteMapDataSource"
StaticMenuStyle-CssClass="StaticMenuStyle"
StaticMenuItemStyle-CssClass="StaticMenuItemStyle"
StaticSelectedStyle-CssClass="StaticSelectedStyle"
StaticHoverStyle-CssClass="StaticHoverStyle"
Orientation="Horizontal"
MaximumDynamicDisplayLevels="0"
runat="server">
</asp:Menu>
It works for StaticMenuStyle-CssClass and StaticMenuStyle-CssClass (the classes are applied to the relevant elements), but StaticSelectedStyle-CssClass and StaticHoverStyle-CssClass are not applied, regardless of the selected or hover status of an element.
What am I supposed to do to make this work?
Thanks.
EDIT: Sorry I should have mentioned that this is .NET 4. Here is the generated HTML:
<div id="NavigationMenu">
<ul class="level1 StaticMenuStyle">
<li><a class="level1 StaticMenuItemStyle selected" href="/Link.aspx">Link</a></li>
</ul>
</div>
So as you can see, StaticMenuStyle and StaticMenuItemStyle are applied, but not StaticSelectedStyle-CssClass or StaticHoverStyle-CssClass. Not sure why. I know I can use selected but isn't the expected behavior that StaticSelectedStyle-CssClass be applied??? By using selected I make assumptions as to what .NET does behind the scenes and that's not right.