0

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

但是,当我在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; } 

任何人有这个问题的经验,知道的方式来解决这个问题?感谢您的帮助。

回答

1

我发现问题所在,我在同一页面上使用JQuery选项卡。这导致dropdownlistfor-s的前端不能缩放到为整个站点设置的css。而是使用JQuery选项卡的前端呈现下拉框,并将前端设置为CSS。

// 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 
    } 
} 

我已使用Javascript功能来设置字体大小的功能的document.ready解决了这个问题