【发布时间】:2012-10-22 23:46:07
【问题描述】:
我的 asp.net mvc 应用程序中有一个简单的 ViewModel 类。
public class DestinationViewModel
{
[Display(Name = "Country")]
[some validation attributes]
public string CountryName { get; set; }
[Display(Name = "Destination")]
[some validation attributes]
public string DestinationName { get; set; }
public DateTime? DepartureDate { get; set; }
public DateTime? ArrivalDate { get; set; }
}
当我将数据传递给控制器时,我的应用程序显示无效出发和到达日期的验证错误。但我不想要这样的行为。是否有任何方法(属性)仅在 DepartureDate 和 ArrivalDate 字段上禁用验证?
【问题讨论】:
-
验证信息是什么?日期时间无效?
-
@jrummell 通常的 ASP.NET 验证消息:“值 '21321' 对 ArrivalDate 无效。”