【问题标题】:IE9 bug with Html.DropDownListFor带有 Html.DropDownListFor 的 IE9 错误
【发布时间】:2012-02-19 11:27:18
【问题描述】:

您好,我需要一些有关 Internet Explorer 9 中的错误的帮助。我目前正在 ASP.NET 4 MVC 3 Razor 中开发一些 CRUD 屏幕。在多屏幕中,我使用 @Html.DropDowListFor 为外键创建简单的链接。

但是当我在 IE9(并且只有 IE9)中很少使用这些时,DropDownList 将呈现小于其通常大小,文本将显示比正常低几个像素,并且如果显示的单词大于少量字符(不确定是多少,我认为大约是 10)它不会被完全渲染。奇怪的是,当我点击 DropDownList 时,它会自行修复。

查看代码:

@Html.DropDownListFor(model => model.Asset.FkAssetTypeId, new SelectList(Model.AssetTypes, "AssetTypeId", "Name"))
@Html.ValidationMessageFor(model => model.Asset.FkAssetTypeId)

型号代码:

[Display(ResourceType = typeof(I18N_Asset), Name = "Label_Asset_FkAssetTypeId")]
public int FkAssetTypeId { get; set; }

任何人都对此问题有任何经验,并且知道解决此问题的方法吗?谢谢你的帮助。

【问题讨论】:

    标签: asp.net-mvc-3 internet-explorer-9 html.dropdownlistfor


    【解决方案1】:

    我找到了问题所在,我在同一页面上使用了 JQuery 选项卡。这导致 dropdownlistfor-s 的 frontsize 无法扩展到为整个站点设置的 css。而是使用 JQuery 选项卡的 frontsize 呈现 dropdownboxfor,然后将 frontsize 设置为 css。

    我已经通过使用 Javascript 在 Document.ready 函数中设置字体大小解决了这个问题:

    // IE9 causes a bug where the dropdownlists will not be displayed correctly because they won't adapt to their current font-size
    // this javascript fixes that by resetting the font-size
    if (window.navigator.systemLanguage && (!document.documentMode || document.documentMode === 9)) { //check if IE9 is being used
        var list = document.getElementsByTagName('Select'); // get all dropdownlists
        for (i = 0; i < list.length; i++) {
            list[i].style.fontSize = list[i].style.fontSize; // reset the font-size
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-03
      • 1970-01-01
      • 1970-01-01
      • 2014-11-21
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      相关资源
      最近更新 更多