Html.DropDownListFor 的 IE9 错误

发布于 2024-12-29 05:40:58 字数 712 浏览 1 评论 0原文

您好,我需要一些有关 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; }

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

Hello I need some help with a bug in Internet Explorer 9. I am currently developing some CRUD screens in ASP.NET 4 MVC 3 Razor. In a multiple screen I use the @Html.DropDowListFor to create easy links for Foreign keys.

But when I few these in IE9 (and only IE9) the DropDownList will be rendered smaller than its usual size, the text will be displayed a few pixels lower than normal, and the if the word that is displayed is larger than a small amount of characters(not sure what number, I think it's about 10) it will not be fully rendered. The weird part is that when I click on the DropDownList it will fix itself.

The View code:

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

The Model code:

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

Anybody have any experience with this issue, and know a way to fix this? thank you for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里梦着梦中梦 2025-01-05 05:40:58

我发现问题是什么,我在同一页面上使用 JQuery 选项卡。这导致 dropdownlistfor-s 的 frontsize 无法缩放到为整个站点设置的 css。而是使用 JQuery 选项卡的 frontsize 呈现下拉框,然后将 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
    }
}

I have found what the problem was, I was using JQuery tabs on the same page. This caused the frontsize of the dropdownlistfor-s to not scale to the css that is set for the whole site. but instead renders the dropdownboxfor with the frontsize of the JQuery tabs and than sets the frontsize to the css.

I have solved this issue by using Javascript to set the font-size in a Document.ready function:

// 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
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文