ここにあるXD Soft jQueryプラグインを使用しようとしています:
datetimepicker NuGet を使用して asp.net mvc プロジェクトにインストールしました。フォーム内でインラインの日付と時刻のピッカーを使用したい HTML は次のとおりです。
<head>
<title>Create</title>
<link rel="stylesheet" href="~/Content/jquery.datetimepicker.css"/>
</head>
<h2>Create</h2>
@using(Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Event</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model =>model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Date, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Date, new { @id = "datetimepicker3", @style ="width:150px" })
@Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
<script type="text/javascript" src="/scripts/jquery.min.js"></script>
<script type="text/javascript" src="/scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.datetimepicker.js"> </script>
<script type="text/javascript">
jQuery('#datetimepicker3').datetimepicker({
format: 'd.m.Y H:i',
inline: true,
lang: 'ru'
});
</script>
@Scripts.Render("~/bundles/jqueryval")
}
ただし、現時点では通常のカレンダーのみが表示され、ユーザーは日付、月、年を選択できますが、必要な時間は選択できません。いくつかの異なるプラグインとチュートリアルを試しましたが、期待どおりに機能するものを入手できませんでした. 私は何年もの間これにこだわっていて、どこにも行けていないので、どんな助けも素晴らしいでしょう。