Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I am using CssClass to change the background image and color of my Menu control in Asp.net. Am using the menu in my MasterPage.

CSS
.mystyle
{
   color:Red ;
   font-size: medium;
   background-image: url('Images/test22.png');
   border-color:Blue;
}


And my Menu is here:

XML
<asp:Menu ID="Menu1" runat="server" CssClass="mystyle"  
    DataSourceID="SiteMapDataSourceMain" >
    <StaticSelectedStyle  CssClass="mystyle"  />
    <StaticMenuItemStyle  CssClass="mystyle" />
    <DynamicHoverStyle CssClass="mystyle" />
    <DynamicMenuStyle CssClass="mystyle" />
    <DynamicItemTemplate >
        <%# Eval("Text") %>
    </DynamicItemTemplate>
    <DynamicSelectedStyle  CssClass="mystyle"  />
    <DynamicMenuItemStyle  CssClass="mystyle" />
    <StaticHoverStyle CssClass="mystyle" />
</asp:Menu>


The problem is when I run for the 1st time, it shows background image. Whenever I refresh the page(a click or something), the background images goes off. It start displaying without any background image. I search for many links but no solution.
Posted
Updated 9-Feb-10 7:08am
v4

 
Share this answer
 
i have done the CSS like below

.myStyle
     {
          background-image: url('Buttons/buttonBackground.png');

     }
      .myStyle1
     {
          background-image: url('Buttons/menuBack.png');
     }


and My menu

<asp:Menu ID="Menu1" runat="server" CssClass="myStyle" 
                            DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                            ForeColor="#7C6F57" Orientation="Horizontal" StaticSubMenuIndent="10px" 
                            DataSourceID="SiteMapDataSource1" StaticDisplayLevels="2">
                            <StaticSelectedStyle BackColor="#CC00CC" />
                            <StaticMenuItemStyle CssClass="myStyle" HorizontalPadding="5px" VerticalPadding="2px" 
                                BackColor="#F3F3EE" />
                            <StaticHoverStyle CssClass="myStyle1" BackColor="#CC00CC" ForeColor="White" />
                            <DynamicHoverStyle CssClass="myStyle" BackColor="#CC00CC" ForeColor="White" />
                            <DynamicMenuStyle BackColor="#F7F6F3" />
                            <DynamicSelectedStyle BackColor="#CC00CC" />
                            <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" 
                                BackColor="#F3F3EE" />
                            <StaticHoverStyle CssClass="myStyle" ForeColor="White" />
                            <Items>

....

....


And Now it is work like a charm...
May be it will help other like me..
 
Share this answer
 
v3
I have already seen it. anyway great link..and thank U.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900