具有MVC2 RTM的DataAnnotationsModelBinder [英] DataAnnotationsModelBinder with MVC2 RTM

查看:76
本文介绍了具有MVC2 RTM的DataAnnotationsModelBinder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用DataAnnotations验证模型,但DefaulModelBinder会覆盖我的Required属性错误消息,并且永远不会将我的错误消息用于无效的数据输入.始终显示值"对于属性名称"无效.

Trying to validate models with DataAnnotations but DefaulModelBinder overrides my Required property error messages and never uses my error messages for invalid data entry. Always show 'value' is invalid for 'property name'.

在另一个问题中,我看到MVC 2使用DataAnnotationsModelBinder,但是在MVC 2二进制文件中找不到任何类.我下载了MVC期货的源代码,并更改了一些源代码以针对.Net 4.0进行编译,但是尽管我可以成功编译,但是它存在兼容性问题,并且无法按预期工作.

In another question I saw that MVC 2 uses DataAnnotationsModelBinder but I couldn't find any class in MVC 2 binaries. I downloaded the source for MVC futures and changed some source to compile it for .Net 4.0 but although I had success to compile, it has compatability problems and doesn't work as expected.

感谢任何帮助.

推荐答案

请勿尝试将DataAnnotationsModelBinder与MVC 2 RTM一起使用. MVC 2 RTM的DefaultModelBinder已经包含DataAnnotationsModelBinder示例中存在的所有逻辑.

Do not try to use the DataAnnotationsModelBinder with MVC 2 RTM. MVC 2 RTM's DefaultModelBinder already contains all of the logic that was present in the DataAnnotationsModelBinder sample.

这篇关于具有MVC2 RTM的DataAnnotationsModelBinder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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