开发者

Data annotations modelbinder in new mvc

开发者 https://www.devze.com 2023-01-20 04:46 出处:网络
Hi we are trying to upgrade our project to work in the latest version of VS 2010 and i have encountered a problem with the old Data Annotations Modelbinder.

Hi we are trying to upgrade our project to work in the latest version of VS 2010 and i have encountered a problem with the old Data Annotations Modelbinder.

Dim modelBinder = New DataAnnotationsModelBinder()

modelBinder.InvalidValueFormatter = _ Function(propDescriptor As PropertyDescriptor, value As String, displayName As String) _ String.Format("'{0}' är ej ett korrekt värde för {1}.", value, 开发者_如何学运维displayName)

        ModelBinders.Binders.DefaultBinder = modelBinder

What Im trying to do is to overide the default errormessage for wrong datainput ("The value '{0}' is not valid for the {1} field.)

I try to get the default modelbinder to assign it a new errormessage


I found this post about this problem which solved my problem:

http://forums.asp.net/p/1512140/3606268.aspx#3606268

0

精彩评论

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