0
我在我的視圖模型是這樣的錯誤消息:如何顯示從DataAnnotationsExtensions而不是DataAnnotations
using System.Web;
using System.ComponentModel.DataAnnotations;
using DataAnnotationsExtensions;
namespace Project.Models.ViewModels
{
public class AddViewModel
{
[Integer(ErrorMessage="ID must be an integer.")]
public int ID { get; set; }
}
}
但是當我運行該程序,顯示錯誤消息將是」字段ID必須是數字「。我認爲這是從System.ComponentModel.DataAnnotations。如何顯示使用DataAnnotationsExtensions創建的錯誤消息? TIA。
來設置該屬性在Global.asax中?試圖添加它,但沒有工作:( – user3350025