缺少此DateTimePicker的实例数据

时间:2014-02-20 07:33:59

标签: c# jquery html-helper datetimepicker jquery-ui-timepicker

我有两个开始日期和结束日期的文本框。在这两个文本框中我使用datepicker。此外,我在这个页面上有一个uplodify。当我在这些文本框上填写日期并点击上传按钮上传图片。我收到了以下错误"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代码:

$('.SelectDate').datepicker({
            });

脚本文件:

请帮我解决这个问题。谢谢。

1 个答案:

答案 0 :(得分:0)

我在使用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);
        }
    });
});