-1

我想显示两个不同的错误消息。首先给出所需的值,第二个给出 Int64 值。这是我的代码。

    [Display(Name = "Employee")]
    [Required]
    public Int64 EmployeeId { get; set; }
4

2 回答 2

1

您可以使用RangeAttribute

[Required(ErrorMessage = "Msg1")]
[Range(10, 1000, 
    ErrorMessage = "Value for {0} must be between {1} and {2}.")]
public object Weight;
于 2013-06-21T08:51:37.457 回答
0

您可以在此处使用数据注释扩展:http: //dataannotationsextensions.org/

然后添加如下两个注解:

[Required(ErrorMessage = "Employee Id is required")]
[DataAnnotationsExtensions.Integer(ErrorMessage = "Please enter a valid number.")]
public Int64 EmployeeId { get; set; }
于 2013-06-21T08:49:03.423 回答