Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 26th, 2010, 05:57 PM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default Page 250 static over styles

Referring closely to the book, I have been working up a site with a vertical menu - and text-only buttons - no images or background color for the static menu.

Master page:

Code:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" StaticEnableDefaultPopOutImage="False">
                <StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
                <StaticHoverStyle CssClass="StaticHoverStyle" />
            </asp:Menu>
                    <asp:SiteMapDataSource ID="SiteMapDataSource1" ShowStartingNode="False" runat="server" />
CSS
Code:
.StaticHoverStyle
{
    /* Defines the look of active and hover menu items */
    color:Blue;
    background-color:#3a3a3a;
}
There is a change to the expected background color when hovering. BUT the color of the font does NOT change. Any suggestions as to why not?
Reply With Quote
  #2 (permalink)  
Old March 26th, 2010, 06:10 PM
Imar's Avatar
Wrox Author
Points: 67,317, Level: 100
Points: 67,317, Level: 100 Points: 67,317, Level: 100 Points: 67,317, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,230
Thanks: 66
Thanked 1,416 Times in 1,396 Posts
Default

Maybe some other rule is more specific? Consider this:

#MainMenu a
{
color: red;
}

.StaticHoverStyle{
color: green;
}

In this case, the rule from #MainMenu a is said to be more specific as it contains an ID and a tag selector (101), instead of just a class selector (10). This means the former rule wins.

Possible ways to fix:

1. Make the other rule less specific

2. Make the hover rule more specific (maybe use .MainMenu .StaticHoverStyle, provided you assigned a class name of MainMenu to the Menu control)

3. Add: !important to the property value:

color: green !important;

You can read more about specificity here:

http://htmldog.com/guides/cssadvanced/specificity/

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
kiwibrit (March 26th, 2010)
  #3 (permalink)  
Old March 26th, 2010, 08:03 PM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default

Thanks, Imar. Following on from your post this has done the trick:

Code:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" StaticEnableDefaultPopOutImage="False" CssClass="MainMenu">
              <StaticSelectedStyle CssClass="StaticSelectedStyle" />
            </asp:Menu>
with CSS
Code:
.MainMenu a, .MainMenu a:visited
{
color: red;
}
        
.MainMenu a:hover
{
color:green;
 background-color:#3a3a3a;
}    

.StaticSelectedStyle{
color: Blue !important;
background-color: Fuchsia;
}
Interesting HTML dog article.
Reply With Quote
  #4 (permalink)  
Old March 27th, 2010, 04:35 AM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default

For those who may have come across this is a search, in the end, for the effect I actually wanted, this did for me:
Code:
.MainMenu 
{
margin:5px 5px;
}
        
 .StaticMenuItemStyle, .StaticMenuItemStyle a, .StaticMenuItemStyle a:visited
 {
   color:White;
   padding:4px 4px;
 }      
 
.StaticHoverStyle
{
    background-color:#AFAFAF;
}

.StaticSelectedStyle
{
    background-color: #404040;
}
Had I wanted a different selected text color, !important after the color property would have been needed.

Last edited by kiwibrit; March 27th, 2010 at 07:37 AM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Static variables in Static Class JoinTTT BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 4 March 29th, 2009 05:08 PM
Invoking selection.js library file in static page Manoah Javascript 2 September 2nd, 2008 04:05 AM
non-static reports to static html files miamikk ASP.NET 2.0 Basics 0 June 4th, 2007 01:48 PM
ASP.NET - Static Page and Dynamic Page sohrabus ASP.NET 2.0 Professional 2 April 18th, 2007 11:42 PM
Ch. 7 - Policy Form (p. 250) MER78 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 September 27th, 2004 03:51 PM



All times are GMT -4. The time now is 05:11 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.