asp.net中的.cs文件中方法的验证
本文关键字:方法 验证 文件 net 中的 cs asp | 更新日期: 2023-09-27 18:04:07
net。。。我正在制作一个简单的MVC项目,并在给定链接中的教程帮助下:
http://www.codeproject.com/Articles/486161/Creating-a-simple-application-using-MVC
我在这个特定的阶段犯了错误。
现在让我们在字段上应用验证:
Error 2 The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
C:'Users'sword'Documents'Visual Studio 2012'Projects'MyCalculatorSrevice'MyMvc1'MyMvc1'Models'UserModels.cs
我搜索了它,但找不到任何可以删除此错误的内容。
帮我解决
乙醇
确保:
- 您引用了System.ComponentModel程序集
- 您已经在UserModel.cs文件中通过
using System.ComponentModel;
导入了注释
希望它能帮助你,
您实际上缺少对DataAnnotations
的引用。尝试在引用中添加以下行,它就会开始工作。
using System.ComponentModel.DataAnnotations;