gpt4 book ai didi

asp.net-mvc - IE 不为 MVC5 呈现 DatePicker

转载 作者:行者123 更新时间:2023-12-05 00:27:17 24 4
gpt4 key购买 nike

正如您已经知道的那样,我正在制作一个 MVC5 站点。现在我刚刚使用具有 BirthDate 字段的 Crete 模板创建了一个 View 。 Andit 没有在 IE 中显示,在 Chrome 中显示得很糟糕,文本框内有很多字形,如下图所示。

enter image description here

发生了什么,我怎样才能让 IE 像 Chrome 一样简单地显示日期选择器,以及如何稍微调整一下。我认为这些杠杆既无用又令人困惑。

这是我在模型中定义该属性的方式

    [Display(Name = "Fecha de nacimiento")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime BirthDate { get; set; }

并在 View 中
    <div class="form-group">
@Html.LabelFor(model => model.BirthDate, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.BirthDate)

@Html.ValidationMessageFor(model => model.BirthDate)
</div>
</div>

最佳答案

如果你不喜欢内置的日期选择器(它被浏览器渲染,因为它是 input type="date"),那么有很多 3rd 方插件可用,比如 jQuery UI .

您可能需要更改的一件事是不要使用 EditorFor您可能需要使用 TextBoxFor所以浏览器只是把它当作一个普通的文本框。下面是一个使用 jQuery UI 的例子:

@Html.TextBoxFor(m => m.BirthDate)

<script>
$(function() {
$('#BirthDate').datepicker();
});

关于asp.net-mvc - IE 不为 MVC5 呈现 DatePicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21055564/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com