1

開始日と終了日用にこれら 2 つのテキストボックスを用意しています。これら 2 つのテキスト ボックスでは、datepicker を使用します。また、このページでアップロードしています。これらのテキストボックスに日付を入力し、アップロードボタンをクリックして写真をアップロードすると. 次のエラーが発生しました"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 に答える