ASP.NET 4.0 删除 controlRenderingCompatibilityVersion=“3.5"后菜单控件的呈现问题 [英] ASP.NET 4.0 Rendering problems with the menu control after removing of controlRenderingCompatibilityVersion="3.5"

查看:32
本文介绍了ASP.NET 4.0 删除 controlRenderingCompatibilityVersion=“3.5"后菜单控件的呈现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上正在将网站迁移到 ASP.NET 4.0,但在菜单控件的新呈现方面遇到了问题.我的网站大量使用嵌套菜单.使用悬停效果,布局由主题和皮肤与链接 CSS 的组合定义.

I am actually migrating websites to ASP.NET 4.0, having problems with the new rendering of menu controls. My websites make heavy use of nested menus. Hover effects are used and the layout is defined by a combination of themes and skins with linked CSS.

如果我删除页面 controlRenderingCompatibilityVersion 属性,它们将不再呈现为嵌套表,而是呈现为 ul/li 标签.这在很多方面打破了我的布局.非常欢迎任何有关迁移复杂 ASP.NET 菜单布局的建议.

If I remove the pages controlRenderingCompatibilityVersion attribute, they are no longer rendered as nested tables, but as ul/li Tags. This breaks my layout in many ways. Any recommendations for a migration of a complex ASP.NET menu layout are very welcome.

已标记和 CSS 详细信息作为对评论的回应

皮肤文件的相关部分

<asp:Menu runat="server" DynamicHorizontalOffset="2" Orientation="Horizontal" SkipLinkText=""
    StaticPopOutImageUrl="~/App_Images/Themes/arrow_down.gif" DynamicPopOutImageUrl="~/App_Images/Themes/arrow_right.gif">
    <StaticMenuItemStyle CssClass="MenuDefaultMenuItemStyle" />
    <DynamicMenuItemStyle  CssClass="MenuDefaultMenuItemStyle" />

    <StaticSelectedStyle CssClass="MenuDefaultSelectedStyle" />
    <DynamicSelectedStyle CssClass="MenuDefaultSelectedStyle" />

    <StaticHoverStyle CssClass="MenuDefaultHoverStyle" />
    <DynamicHoverStyle CssClass="MenuDefaultHoverStyle" />
</asp:Menu>

<asp:Menu runat="server" SkinId="MenuVertical" DynamicHorizontalOffset="2" SkipLinkText=""
    StaticPopOutImageUrl="~/App_Images/Themes/arrow_right.gif" DynamicPopOutImageUrl="~/App_Images/Themes/arrow_right.gif">
    <StaticMenuItemStyle CssClass="MenuVerticalMenuItemStyle" />
    <DynamicMenuItemStyle  CssClass="MenuVerticalMenuItemStyle" />

    <StaticSelectedStyle CssClass="MenuVerticalSelectedStyle" />
    <DynamicSelectedStyle CssClass="MenuVerticalSelectedStyle" />

    <StaticHoverStyle CssClass="MenuVerticalHoverStyle" />
    <DynamicHoverStyle CssClass="MenuVerticalHoverStyle" />
</asp:Menu>

样式表

.MenuDefaultMenuItemStyle
{
    background-color: #D5DCE1;
    color: #234875;
    padding: 2px;
    width: 100%;
}

.MenuDefaultSelectedStyle
{
    background-color: #3C5778;
    color: #FFFFFF;
    padding: 2px;
    width: 100%;
}

.MenuDefaultHoverStyle
{
    background-color: #666666;
    color: #FFFFFF;
    padding: 2px;
    width: 100%;
}

.MenuVerticalMenuItemStyle
{
    background-color: #FFFFFF;
    border: 1px solid #D5DCE1;
    color: #234875;
    height: 30px;
    padding: 2px;
    width: 100%;
}

.MenuVerticalSelectedStyle
{
    background-color: #003366;
    border: 1px solid #D5DCE1;
    color: #FFFFFF;
    height: 30px;
    padding: 2px;
    width: 100%;
}

.MenuVerticalHoverStyle
{
    background-color: #EEEEEE;
    border: 1px solid #000000;
    color: #234875;
    height: 30px;
    padding: 2px;
    width: 100%;
}

推荐答案

如果您从 web.config 中删除 controlRenderingCompatibilityVersion 属性,则菜单呈现的默认模式会从 TableList.如果您仍然希望使用表格标签呈现菜单,您需要通过添加 RenderingMode 属性在 asp:menu 控件中明确指定:

If you remove the controlRenderingCompatibilityVersion attribute from web.config the default mode for menu rendering changes implicitely from Table to List. If you still want to have your menu rendered with table tags you need to specify this explicitely in your asp:menu control by adding the RenderingMode attribute:

<asp:Menu runat="server" RenderingMode="Table" ... >
   ...
</asp:Menu>

(也是 MSDN 中的备注部分:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.renderingmode.aspx)

(s. also the remarks section here in MSDN: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.renderingmode.aspx)

这篇关于ASP.NET 4.0 删除 controlRenderingCompatibilityVersion=“3.5"后菜单控件的呈现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆