在 mvc 2 中本地化默认模型验证
[Required]
[DisplayName("my date")]
public DateTime? DateReg { get; set; }
因此,如果用户要传递无效的日期时间值,他将收到此消息 “值‘02.07.201022’对于我的日期无效。”
我该如何翻译/本地化此消息?
[Required]
[DisplayName("my date")]
public DateTime? DateReg { get; set; }
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
App_GlobalResources
和Global.asax
中的Application_Start
中添加Messages.resx
:然后在
Messages 中添加
文件中,您可以定义以下字符串:Messages.resx
。在 resxPropertyValueInvalid: The value {0} is invalid for the property {1}
该键需要被称为
PropertyValueInvalid
。Add
Messages.resx
inApp_GlobalResources
and inApplication_Start
inGlobal.asax
:Then in the
Messages.resx
file you could define the following string:PropertyValueInvalid: The value {0} is invalid for the property {1}
The key needs to be called
PropertyValueInvalid
.