Solved

duplicate background images in asp.net menuitem

Posted on 2006-10-19
5
1,639 Views
Last Modified: 2007-12-19
I am trying to change the look of the asp.net menu by setting a background image in my stylesheet but in the menu I get duplicate backgrounds like a separate background for the text in that menu item. I have written the following in the stylesheet:

.menuitem
{
      background-image:url(./images/menu_bg.gif);
      width:180px;
      height:25px;
      color:White;
      background-repeat:no-repeat;
}

and the source for the menu looks like this:

<asp:Menu ID="Menu1" runat="server">
                            <LevelMenuItemStyles>
                                <asp:MenuItemStyle BackColor="White" CssClass="menuitem" Font-Underline="False" ItemSpacing="5px" />
                            </LevelMenuItemStyles>
                            <Items>
                                <asp:MenuItem Text="Overview" Value="Overview"></asp:MenuItem>
                                <asp:MenuItem Text="Contacts" Value="Contacts"></asp:MenuItem>
                            </Items>
                        </asp:Menu>

Am I missing something?
0
Comment
Question by:Steverino541
  • 2
5 Comments
 
LVL 30

Expert Comment

by:VirusMinus
ID: 17766212
try

#Menu1
{
     background-image:url(./images/menu_bg.gif);
     width:180px;
     height:25px;
     color:White;
     background-repeat:no-repeat;
}


or better still.. once your page is rendered.. do a view source and paste the HTML here. we can then track down what level / element needs to be styled.
0
 

Author Comment

by:Steverino541
ID: 17766269
Here is how the colde locks in html:

<tr style="height:2px;">
            <td></td>
      </tr><tr style="height:2px;">
            <td></td>
      </tr><tr onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="ctl00_Menu1n2">
            <td><table class="menuitem ctl00_Menu1_6" cellpadding="0" cellspacing="0" border="0" width="100%">
                  <tr>
                        <td style="white-space:nowrap;width:100%;"><a class="ctl00_Menu1_1 menuitem ctl00_Menu1_5" href="javascript:__doPostBack('ctl00$Menu1','Contacts')" style="border-style:none;font-size:1em;">Contacts</a></td>
                  </tr>
            </table></td>
      </tr>
0
 
LVL 30

Accepted Solution

by:
VirusMinus earned 250 total points
ID: 17895076
ok there look to be multiple classes being applied to elements here:

<table class="menuitem ctl00_Menu1_6" ... is applying .menuitem AND .ctl00_Menu1_6, track this down in your css

also look at <td style="white-space:nowrap;width:100%;"><a class="ctl00_Menu1_1 menuitem ctl00_Menu1_5"  three different classes are being applied here, including .menuitem which might explain the background for the table and the text.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now