I'm pretty new to .net and c# and im trying to change the back colour of the menu items in my navigation bar..the code i have so far looks somethinig like this
I copied and pasted your menu code and ran the page. They showed up red for me. Maybe you have CSS that's causing your troubles (?). Try removing the CssClass="menu" and see...
Also, in the code you posted, I think you want to use StaticHoverStyle since you're menu items are static not dynamic. Same for the other style attributes/lines.
Yeah turns out my CSS where causing me problems once i got in there I changed it and it worked and I am using the static thanks! Been hacking at this for hours!
Cripper3
Member
2 Points
5 Posts
How to change the colour of a menu item
Sep 02, 2013 10:06 AM|LINK
I'm pretty new to .net and c# and im trying to change the back colour of the menu items in my navigation bar..the code i have so far looks somethinig like this
<div class="clear hideSkiplink" style="background-color: red">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
EnableViewState="False" Orientation="Horizontal"
BackColor="red" ForeColor="black" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.8em" StaticSubMenuIndent="10px">
<DynamicHoverStyle BackColor="red" ForeColor="White" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyle BackColor="red" />
<DynamicSelectedStyle BackColor="red" />
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
<asp:MenuItem NavigateUrl="~/Account/MembersOnly.aspx" Text="Staff"
Value="Staff"></asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="red" ForeColor="White" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticSelectedStyle BackColor="red" />
</asp:Menu>
</div>
</div>
the menu items keep appearing in the default green/blue colour and I want to change them to a different colour eg. red any idea how to do this?
c#menuitems
MetalAsp.Net
All-Star
117319 Points
19334 Posts
Moderator
Re: How to change the colour of a menu item
Sep 02, 2013 10:20 AM|LINK
I copied and pasted your menu code and ran the page. They showed up red for me. Maybe you have CSS that's causing your troubles (?). Try removing the CssClass="menu" and see...
Also, in the code you posted, I think you want to use StaticHoverStyle since you're menu items are static not dynamic. Same for the other style attributes/lines.
c#menuitems
Cripper3
Member
2 Points
5 Posts
Re: How to change the colour of a menu item
Sep 02, 2013 10:28 AM|LINK
Yeah turns out my CSS where causing me problems once i got in there I changed it and it worked and I am using the static thanks! Been hacking at this for hours!
c#menuitems