我想显示两个不同的错误消息。首先给出所需的值,第二个给出 Int64 值。这是我的代码。
[Display(Name = "Employee")]
[Required]
public Int64 EmployeeId { get; set; }
我想显示两个不同的错误消息。首先给出所需的值,第二个给出 Int64 值。这是我的代码。
[Display(Name = "Employee")]
[Required]
public Int64 EmployeeId { get; set; }
您可以使用RangeAttribute。
[Required(ErrorMessage = "Msg1")]
[Range(10, 1000,
ErrorMessage = "Value for {0} must be between {1} and {2}.")]
public object Weight;
您可以在此处使用数据注释扩展:http: //dataannotationsextensions.org/
然后添加如下两个注解:
[Required(ErrorMessage = "Employee Id is required")]
[DataAnnotationsExtensions.Integer(ErrorMessage = "Please enter a valid number.")]
public Int64 EmployeeId { get; set; }