我有两个用于开始日期和结束日期的文本框。在这两个文本框中,我使用日期选择器。我也在这个页面上有一个更新。当我在这些文本框上填写日期并单击上传按钮上传图片时。我收到以下错误"Missing Instance Data for this DateTimePicker"
HTml的代码:
<div class="clearfix mrb10">
<div class="vp-dt-left">@Resources.Languages.Start<span class="orange">*</span>:</div>
<div class="vp-dt-right">
@Html.TextBoxFor(m => m.StartDate, "{0:d}", new { @class = "vp-box-input-125 SelectDate requiredField", @readonly = "readonly", @Style = "width:72px!important;" })
</div>
</div>
<div class="clearfix">
<div class="vp-dt-left">@Resources.Languages.End<span class="orange">*</span>:</div>
<div class="vp-dt-right">
@Html.TextBoxFor(m => m.EndDate, "{0:d}", new { @class = "vp-box-input-125 SelectDate requiredField", @readonly = "readonly", @Style = "width:72px!important;" })
</div>
</div>
Jquery Code:
$('.SelectDate').datepicker({
});
脚本文件:
请帮我解决这个问题。谢谢。
我在使用 jquery datepicker 的代码中做了同样的事情。希望对您有所帮助:-
@Html.TextBoxFor(m => m.FromDate, new { style = "width: 200px;" })
@Html.TextBoxFor(m => m.ToDate, new { style = "width: 200px;" })
<script type="text/javascript">
$(document).ready(function () {
$("#ToDate").datepicker(
{
beforeShow: function (input, inst) {
inst.dpDiv.css({ marginTop: -input.offsetHeight + 'px', marginLeft: input.offsetWidth + 'px' });
},
changeYear: true,
yearRange: '-2:' + new Date().getFullYear(),
onClose: function (selectedDate) {
$("#FromDate").datepicker("option", "maxDate", selectedDate);
},
});
$("#FromDate").datepicker(
{
beforeShow: function (input, inst) {
inst.dpDiv.css({ marginTop: -input.offsetHeight + 'px', marginLeft: input.offsetWidth + 'px' });
},
changeYear: true,
yearRange: '-2:' + new Date().getFullYear(),
onClose: function (selectedDate) {
$("#ToDate").datepicker("option", "minDate", selectedDate);
}
});
});