开发者

Custom errormessages using database for dataannotations in MVC 3

开发者 https://www.devze.com 2023-03-09 23:51 出处:网络
I\'m trying to implement a c开发者_如何学JAVAustom class for dataannotations that retrieves error messages from a database. The database part is all done using EF and LINQ to return the messages.

I'm trying to implement a c开发者_如何学JAVAustom class for dataannotations that retrieves error messages from a database. The database part is all done using EF and LINQ to return the messages.

[Required(ErrorMessageResourceType=typeof(MyTestClass), ErrorMessageResourceName="Required")]

What does my class need to return for it to work? Works with resource-file, but I really need to put it in database. And it should work for StringLength and other validation attributes.

I'm really stuck on this one, so I'd appreciate some code to solve this issue.

/Lasse


http://blog.gauffin.org/2010/11/simplified-localization-for-dataannotations/

0

精彩评论

暂无评论...
验证码 换一张
取 消