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解決了這個問題