在学习本教程时(http://www.asp.net/mvc/tutorials/javascript/using-the-html5-and-jquery-ui-datepicker-popup-calendar-with-aspnet-mvc/using-the-html5 -and-jquery-ui-datepicker-popup-calendar-with-aspnet-mvc-part-4),我尝试通过NuGet安装jQuery UI WIdgets:Datepicker并得到以下错误:
试图解决依赖'jQuery.UI.Core(= 1.8.9)'.
试图解决依赖'jQuery(≥1.4.4&& <1.6)'.
成功安装了"jQuery 1.4.4".
成功安装'jQuery.UI.Core 1.8.9'.
成功安装'jQuery.UI.Widgets.Datepicker 1.8.9'.
安装失败.滚回来...
将"jQuery 1.7.1.1"更新为"jQuery 1.4.4"失败.无法找到与'jQuery 1.4.4'兼容的'jQuery.UI.Combined'版本.
这可能是因为我在其他方面的解决方案中有jQuery 1.7.1.1.我怎么能绕过这个?
如果我不能,是否有另一个日期选择器,我可以在ASP .NET MVC 4(我是新手)中使用明确的使用说明?
标题说明了一切.该模型不需要StartDate字段,但在POST上我告知它是必需的.它是几个搜索字段之一,每个字段都是可选的.因此,我没有检查IsModel.Valid,所以无论如何搜索仍然有效,但消息显示在屏幕上.如果我在视图中设置@ Html.ValidationSummary(true),它会隐藏消息,但字段仍然变为红色.
此外,我确实有一个检查,以确保EndDate晚于StartDate,所以我需要显示错误/请求字段的消息,而不是在没有错误时.
这是代码:
型号(部分)
[Display(Name = "Start Date")]
[DataType(DataType.Date)]
public DateTime StartDate { get; set; }
[Display(Name = "End Date")]
[GreaterThanOrEqualTo("StartDate", ErrorMessage = "End Date must be later than Start Date")]
[DataType(DataType.Date)]
public DateTime EndDate { get; set; }
Run Code Online (Sandbox Code Playgroud)
查看(部分)
@using (Html.BeginForm()){
@Html.ValidationSummary(false)
<table>
<tr>
<td>
@Html.DisplayNameFor(m => m.StartDate)
@Html.TextBox("StartDate", "", new { @class = "datefield" })
etc.
Run Code Online (Sandbox Code Playgroud)
共享/显示模板
@model Nullable<DateTime>
@(Model != null ? string.Format("{0:M/d/yyyy}", Model) : string.Empty)
Run Code Online (Sandbox Code Playgroud)
共享/编辑模板
@model Nullable<DateTime>
@{
DateTime dt = DateTime.Now;
if (Model …Run Code Online (Sandbox Code Playgroud)