1

我有这两个用于开始日期和结束日期的文本框。在这两个文本框上,我使用 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({
            });

脚本文件:

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

4

1 回答 1

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);
        }
    });
});

于 2014-02-20T07:43:21.333 回答