DatePicker 您好,我想用一个月和几年替换这个日期选择器。在我的模型中,我有这段代码:
[Required]
[DataType(DataType.Date)]
[Display(Name = "Select Month")]
[DisplayFormat(DataFormatString = "{0:MM/yyyy}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> Month { get; set; }
在我看来,我有这个:
<div class="col-sm-9">
Current Month : <span>@Convert.ToDateTime(Model.Month).ToString("MMM-yyyy")</span>
@Html.EditorFor(model => (model.Month), new { htmlAttributes = new { @class = "form-control input-circle " } })
@Html.ValidationMessageFor(model => model.Month, "", new { @class = "text-danger " })
</div>
答案 0 :(得分:0)
您认为
@Html.TextBoxFor(a => a.model.Month, "{0:MM/yyyy}", new { @class = "form-control"})
添加JqueryUi脚本。
$(function () {
$("#Month").datepicker();
})