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 October 18th, 2010, 06:43 AM
Registered User
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 DynamicMenuItemStyle not working

Hello,

I am having a problem making the DynamicMenuItemStyle class work on the Monochrome menu. When you hover the mouse over a main menu, the submenus appear showing white text on a light grey background which is correct. However, when you hover a mouse over a submenu, its background color does not change - the background remains light grey rather than displaying the darker gey of #707070.

The menu code is:

Code:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"
Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
                    
<StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
<StaticHoverStyle CssClass="StaticHoverStyle" />
<StaticSelectedStyle CssClass="StaticSelectedStyle" />
<DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />
<DynamicHoverStyle CssClass="DynamicHoverStyle" />
                                        
</asp:Menu>
The CSS code that is relevant to the menu is written as


Code:
.StaticMenuItemStyle, .StaticMenuItemStyle a 
{
	/* Defines the look of main menu items. */
	color: #707070;
	font-size: 14px;
	font-weight: bold;
	text-decoration: none;
	padding-left: 2px;
}

.StaticHoverStyle, .StaticSelectedStyle
{
	/* Defines the look of active and hover menu items */
	background-color: #c1e4ce;
}

.DynamicMenuItemStyle
{
	/* Defines the sub menu items */
	font-size: 14px;
	color: #707070;
	background-color: #cccccc;
	padding: 4px 2px 4px 3px;
}

.DynamicHoverStyle
{
	/* Defines the hover style of sub menus */
	background-color: #707070;
	color: White;
}

.DynamicHoverStyle a
{
	/* Removes the underline from links in the sub menus */
	text-decoration: none;
}
No matter what values I place within the .DynamicHoverStyle and .DynamicHoverStyle a classes, there is no effect in the browser. Don't think there are any typos or mistakes but I could be wrong?

I am using VWD 2010 rather than 2008 should that make a difference. And viewing it in FireFox 3.6.10 and IE 8.

Any help with this issue will be gratefully received.

Regards

Robbie

Last edited by robbiethompson73; October 18th, 2010 at 06:53 AM.
Reply With Quote
  #2 (permalink)  
Old October 18th, 2010, 06:54 AM
Imar's Avatar
Wrox Author
Points: 67,578, Level: 100
Points: 67,578, Level: 100 Points: 67,578, Level: 100 Points: 67,578, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,268
Thanks: 66
Thanked 1,428 Times in 1,408 Posts
Default

Hi Robbie,

Quote:
I am using VWD 2010 rather than 2008 should that make a difference.
Yes, it does, as in ASP.NET 4 (which is what I assume you're using) the menu renders completely different code.

You can set the rendering compatibilty to 3.5 in web.config like this to force 3.5 behavior:

Code:
 
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
Alternatively, you can download the code from the 4.0 book and look at its source for the menu to see how it's done.

Cheers,

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
  #3 (permalink)  
Old July 27th, 2011, 01:45 PM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post
Hi Robbie,

Yes, it does, as in ASP.NET 4 (which is what I assume you're using) the menu renders completely different code.

You can set the rendering compatibilty to 3.5 in web.config like this to force 3.5 behavior:

Code:
 
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
...........

I transferred a site to a web host using 4.0 - and needed a temporary fix to overcome a menu problem, pending a proper sort out, and came across this thread.

Imar's solution worked fine - once I dropped it into the <system.web> section. Obvious really, but it caught me out for a minute or two (it's been a while since I worked in asp.net) and, as this is a beginner's book, I thought I'd drop a note in here, in case anyone got stuck with a similar problem.

PS I had needed an App_Browsers file for the Safari browser when the site was hosted in real 3.5. In 4, it was no longer needed for good rendition in Safari, and indeed the file had to be excluded.

Last edited by kiwibrit; July 28th, 2011 at 04:15 PM. Reason: Clearer explanation
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
Working through Chapter 1 Geoffrey Chambers BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 1 January 2nd, 2010 11:38 PM
Chapter 6: store not working Giorgio84 BOOK: Beginning Ruby on Rails 2 June 18th, 2007 12:17 AM
Chapter 1, First App, No, it's not working redthor BOOK: Beginning Ruby on Rails 2 February 1st, 2007 08:32 PM
Working Code for Chapter 4 clomby BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 1 December 26th, 2005 06:44 AM
CHAPTER 18 example not working also! diegoborgh BOOK: Beginning JavaServer Pages 0 May 27th, 2005 12:16 AM



All times are GMT -4. The time now is 01:28 AM.


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