本地化默认模型验证的MVC 2 [英] localize default model validation in mvc 2

查看:126
本文介绍了本地化默认模型验证的MVC 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[Required]
[DisplayName("my date")]
public DateTime? DateReg { get; set; }

因此​​,如果用户要在一个无效的日期时间值传递,他将得到这个消息
'02 .07.201022'是无效的日期我的价值。

so if the user is going to pass in an invalid datetime value he will get this message "The value '02.07.201022' is not valid for my date."

我怎么能翻译/本地化此消息?

how can I translate/localize this message ?

推荐答案

App_GlobalResources文件和在的Application_Start 的Global.asax

DefaultModelBinder.ResourceClassKey = "Messages";

然后在 Messages.resx 文件,您可以定义以下字符串:

Then in the Messages.resx file you could define the following string:

PropertyValueInvalid:值{0}是无效的属性{1}

PropertyValueInvalid: The value {0} is invalid for the property {1}

关键需求 PropertyValueInvalid

这篇关于本地化默认模型验证的MVC 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆