biz*_*zon 3 c# asp.net-mvc attributes
我正在为我的ASP MVC应用程序进行本地化,我想为每个属性设置相同的设置.
例如:
[Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "RequiredAttribute_ValidationError")]
[Display(Name = "Has?o")]
public string Password { get; set; }
Run Code Online (Sandbox Code Playgroud)
有没有办法自动完成?
创建CustomRequiredAttribute后,您应该在Global.asax中注册您的自定义属性
protected void Application_Start()
{
DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CustomRequiredAttribute), typeof(RequiredAttributeAdapter));
...
Run Code Online (Sandbox Code Playgroud)
来源:http://forums.asp.net/t/1528277.aspx