cannot set menu item color

Last post 11-13-2009 11:49 AM by jpatfburg. 6 replies.

Sort Posts:

  • cannot set menu item color

    11-12-2009, 1:08 PM
    • Member
      point Member
    • jpatfburg
    • Member since 11-12-2009, 12:48 PM
    • Posts 4

    I'm having problems setting the color for the menu items on my menu control. Here's the situation. I have a user control that includes a menu control. When I place this on a page that references a stylesheet, the fore-color of the menu items matches the color specified in the A:link color of the stylesheet (blue). I've set the fore-color of the menu items to white through the Forecolor property of the menu control, as well as in the StaticMenuItemStyle. In the IDE the menu items display in white, but in the browser they display in blue. If I change the A:link color in the stylesheet, the menu items take on the color specified in A:link. Any ideas?

  • Re: cannot set menu item color

    11-12-2009, 3:24 PM
    • Member
      588 point Member
    • Ahmed Moosa
    • Member since 10-01-2009, 10:58 PM
    • Egypt
    • Posts 105

    Hi

    This Normal

    a:Link specified the Link Color

    You May Want To use This

    a:visited   To Visited Link

    Or

    a:hover  To Mouse Over

    Or

    a:active     when Click Link


    Hope this Help


    My Blog

    الحمد لله رب العالمين
  • Re: cannot set menu item color

    11-12-2009, 3:35 PM
    • Member
      point Member
    • jpatfburg
    • Member since 11-12-2009, 12:48 PM
    • Posts 4

    Thanks for your reply, but I don't think that will help. The problem is that I have links on the page that I want displayed in blue. However, the menu items I want displayed in white. I thought that if I set the style for the menu control to forecolor = white, the menu items should display in white. All documentation I've seen indicates this is the way it should be. And if I remove the reference to the CSS on the parent page the menu items do display correctly, however the hyperlinks do not. I'm not clear on why the stylesheet is overriding the inline settings, or how to overcome that.


  • Re: cannot set menu item color

    11-12-2009, 4:13 PM
    • Member
      588 point Member
    • Ahmed Moosa
    • Member since 10-01-2009, 10:58 PM
    • Egypt
    • Posts 105

    Ok Try This


    #menuID a:Link
    {
     color : white ;
    }

    Tell Me If It Work


    My Blog

    الحمد لله رب العالمين
  • Re: cannot set menu item color

    11-12-2009, 7:04 PM
    • Member
      point Member
    • jpatfburg
    • Member since 11-12-2009, 12:48 PM
    • Posts 4

    Thanks for the help, but that didn't work either. Seems like it should. This is confusing...

  • Re: cannot set menu item color

    11-13-2009, 3:24 AM
    Answer
    • Member
      588 point Member
    • Ahmed Moosa
    • Member since 10-01-2009, 10:58 PM
    • Egypt
    • Posts 105

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ahmed</title>
        
        <style type="text/css" runat="server"   >
        #Menu1 a:Link
        {
            color:Red ;
        }    
        a:Link
        {
            color:Blue; 
        }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Menu ID="Menu1" runat="server">
            <Items >
                <asp:MenuItem Text="aaaa" ></asp:MenuItem>
                <asp:MenuItem Text="bbbb"></asp:MenuItem>        
            </Items>
            </asp:Menu>  
            <br />
            <a href="Default2.aspx" >aaaaaaaaaaaaaaaaaaaaaaaa</a> 
            <a href="Default2.aspx" >aaaaaaaaaaaaaaaaaaaaaaaa</a>            
        </div>
        </form>
    </body>
    </html>


    I Try This and work good

    (menu item with color red and other links with blue)

    My Blog

    الحمد لله رب العالمين
  • Re: cannot set menu item color

    11-13-2009, 11:49 AM
    • Member
      point Member
    • jpatfburg
    • Member since 11-12-2009, 12:48 PM
    • Posts 4

    This looks like it should work, but it doesn't. I think the problem must be that I'm not referencing the control correctly, but I'm not sure how to do it. Here are some snippets:

    The menu control is located on the headernav.ascx user control (I created that because it is used for navigation on several pages):

         <asp:Menu ID="mnuUser" runat="server" Font-Bold="True" Font-Names="Arial"
            Font-Size="XX-Small" ForeColor="White" Orientation="Horizontal"
            style="margin-top: 0px">

    (you notice I've assigned the forecolor here, and it displays correctly if I remove the reference to the stylesheet on the container page)


    The headernav.ascx control is placed on the page:

    <%@ Register src="headernav.ascx" tagname="header" tagprefix="uc1" %>

    .

    .

    <head runat="server">
        <title>apptitle</title>
        <link media="screen" href="mycss.css" type="text/css" rel="Stylesheet" />
    </head>

    <body>
        <form id="frm" runat="server">

    <div>
            <uc1:header ID="header1" runat="server" />

    </div> 


    Even if I remove the reference to the stylesheet and drop in your code (with #Menu1 changed to #mnuUser) the links on both the page and the navigation bar are displayed in blue. I tried changing the reference to #header1 but that didn't work either.


Page 1 of 1 (7 items)