我正在尝试使用以下链接将 jquery 日期时间选择器放在文本框中
当我单击日期文本框时,我无法在视图中看到日期时间选择器,为此我已经这样做了.. 这是我的观点
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
<script src="~/Scripts/jquery-ui-1.8.20.min.js"></script>
<script src="~/Scripts/RangeDateValidator.js"></script>
<script src="~/Scripts/jquerydatetimepicker.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.date').datepicker({ dateFormat: "dd/mm/yy" });
// $('.date').datetimepicker();
});
</script>
@model MvcSampleApplication.Models.DateEditModel
@{
ViewBag.Title = "EditDateTimePick";
//Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>EditDateTimePick</h2>
@using (Html.BeginForm())
{
@Html.EditorFor(s=>s.DtpJqry)
<input id="submit" name="submit" type="submit" value="Save" />
}
这是我的控制器部分
public class DateTimePickersController : Controller
{
public ActionResult Index()
{
return View("EditDateTimePick");
}
[HttpGet]
public ActionResult Edit()
{
DateEditModel model = new DateEditModel();
{
var datetimechange = new DatePickerJquery { Name = "Raj", date = new DateTime(2010, 12, 15) };
};
return View(model);
}
public ActionResult Edit(DatePickerJquery dtpjquery)
{
string message = null;
if (ModelState.IsValid)
{
message = "Saved" + DateTime.Now;
}
DateEditModel models = new DateEditModel {
DtpJqry = dtpjquery,
Message = message
};
return View(models);
}
}
这是另一种观点
@model DateTime
@Html.TextBox("", Model.ToString("dd/MM/yyyy"), new { @class = "date" })
修改后的视图:
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
<script src="~/Scripts/RangeDateValidator.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.date').datepicker({ dateFormat: "dd/mm/yy" });
// $('.date').datetimepicker();
});
</script>
@model MvcSampleApplication.Models.DateEditModel
@{
ViewBag.Title = "EditDateTimePick";
//Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>EditDateTimePick</h2>
@using (Html.BeginForm())
{
@Html.EditorFor(s=>s.DtpJqry)
<input id="submit" name="submit" type="submit" value="Save" />
}
任何人请提出任何关于它如何不显示日期时间选择器的想法,这将非常感谢我提前多谢....