这是示例代码。在加载时,我可以看到 dateofbirth 更改为 08-06-1990,但在单击文本框时未显示 datepicker。layout.cshtml 包含以下内容
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
我可以看到它们已加载到 firebug 中。我已经删除了 EditorFor,而是仅用于测试。任何的想法。
@model SMS.Model.Student
@{
ViewBag.Title = "Edit";
}
<script type="text/javascript">
$(document).ready(function(){
$('#DateofBirth').val("08-06-1990");
$('#DateofBirth').datepicker();
});
</script>
<h2>Edit</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Student</legend>
@Html.HiddenFor(model => model.Id)
<div class="editor-label">
@Html.LabelFor(model => model.RegistrationNo)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.RegistrationNo)
@Html.ValidationMessageFor(model => model.RegistrationNo)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DateofBirth)
</div>
<input id="DateofBirth" value="07-06-1990" />
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}