Microsoft KB Archive/911717

= The CssClass property does not affect the MenuLabelHoverStyle, MenuPopupStyle, MenuVerbHoverStyle, MenuVerbStyle, and MenuCheckImageStyle properties in ASP.NET 2.0 =

Article ID: 911717

Article Last Modified on 3/2/2006

-

APPLIES TO


 * Microsoft ASP.NET 2.0

-





SYMPTOMS
Consider the following scenario:
 * In Microsoft ASP.NET 2.0, you try to use a style object of the System.Web.UI.WebControls.WebParts.WebPartZoneBase class.
 * You try to assign the style object by using the CssClass property.
 * You try to use the style object in the WebPartZone server control.

In this scenario, the style does not change as expected. Specifically, the CssClass property does not affect the following style objects:
 * The MenuLabelHoverStyle property
 * The MenuPopupStyle property
 * The MenuVerbHoverStyle property
 * The MenuVerbStyle property
 * The MenuCheckImageStyle property



WORKAROUND
To work around this problem, use inline style attributes for these style objects instead of using the external CssClass property. For example, do not use the following line of code.  Note In this example, wp_menupopup is the class name of a style rule that defines the background color for elements.

Instead, use the following line of code. 



Steps to reproduce the problem
 In Microsoft Visual Studio 2005, click File, and then click New Web Site. In the Templates list, click ASP.NET Web Site. In the Location box, type, and then click OK.

Note  is a placeholder for the location in which the blank ASP.NET Web site is created. In Solution Explorer, right-click Default.aspx, and then click Open.  In the code designer, replace the existing code with the following code. <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; > <head id=&quot;Head1&quot; runat=&quot;server&quot;> Test Page for KB911717  <form id=&quot;form1&quot; runat=&quot;server&quot;> <asp:WebPartManager ID=&quot;WebPartManager1&quot; runat=&quot;server&quot;> </asp:WebPartManager> <asp:WebPartZone ID=&quot;WebPartZone1&quot; runat=&quot;server&quot;> <MenuPopupStyle CssClass=&quot;wp_menupopup&quot; /> <ZoneTemplate> <asp:calendar id=&quot;cal1&quot; runat=&quot;server&quot; /> </ZoneTemplate> </asp:WebPartZone> </li> On the Website menu, click Add New Item.</li> In the Templates list, click Style Sheet, type Stylesheet.css, and then click Add.</li>  In the code designer, replace the contents of the Stylesheet.css file with the following code. .wp_menupopup {   background-color:Red } </li> On the Debug menu, click Start Debugging.

Note If you are prompted to add a Web.config file that has debugging enabled, click OK.</li> When the Default.aspx page opens, click the arrow on the upper-right corner of the Web Part. The background color of the menu is not red as you specified in the Stylesheet.css file.</li></ol>

<div class="references_section">