我對web開發的世界很陌生。我正在學習Asp.net MVC,我想創建一個簡單的表單元素,讓用戶從使用jQuery注入的日期選擇器中選擇日期。這是我迄今已完成,jQuery DatePicker不會出現asp.net
我加入到jQuery庫的引用版式文件「_Layout.cshtml」像這樣:
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="~/Scripts/jquery.validate-vsdoc.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/knockout-2.2.0.debug.js"></script>
<script src="~/Scripts/knockout-2.2.0.js"></script>
<script src="~/Scripts/modernizr-2.6.2.js"></script>
</head>
這是我想渲染視圖包含一個文本框元素使用剃鬚刀插入日期生成。表格前插入一個簡單的jQuery腳本注入日期選擇器,但我不能選擇後,我跑的形式
model MvcApplication3.Models.RegisterModel
@{
ViewBag.Title = "Register";
}
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>Create a new account.</h2>
</hgroup>
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script>
$(document).ready(function() {
$('#BirthDate').datepicker({
showOn: "button",
buttonImage: "/images/calendar-icon.png",
buttonImageOnly: true,
buttonText: "Select date"
});
});
</script>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<fieldset>
<legend>Registration Form</legend>
<ol>
<li>
@Html.LabelFor(model => model.UserName)
@Html.TextBoxFor(m => m.UserName)
</li>
<li>
@Html.LabelFor(model => model.Password)
@Html.PasswordFor(model => model.Password)
</li>
<li>
@Html.LabelFor(model => model.ConfirmPassword)
@Html.PasswordFor(model => model.ConfirmPassword)
</li>
<li>
@Html.LabelFor(model => model.Email)
@Html.TextBoxFor(model => model.Email)
</li>
<li>
@Html.LabelFor(model => model.BirthDate)
@Html.TextBoxFor(model => model.BirthDate)
</li>
</ol>
<input type="submit" value="Register" />
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
這是呈現HTML日期:
每當我點擊出生日期TextBox我什麼也沒有
如果在'fieldset'之後移動包含初始化的腳本,它會工作嗎?此外,刪除'',該文件已經加載到'head'中。 –
謝謝您的建議,但它也不起作用 –
這很奇怪......它是什麼不實際工作?日期選擇器是否彈出或不彈出?刪除所有選項並讓默認設置查看是否顯示。 –