繁体   English   中英

验证.asp文件中.cs文件中的方法

[英]Validation of method in .cs file in asp.net

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

我进行了搜索,但找不到任何可消除此错误的信息。

帮帮我

感谢名单

确保 :

  1. 您已经引用了System.ComponentModel程序集
  2. 您已经using System.ComponentModel;导入了注释using System.ComponentModel; 在您的UserModel.cs文件中。

希望对你有帮助

您实际上缺少对DataAnnotations引用。 尝试在参考之间添加以下行,它将开始工作。

using System.ComponentModel.DataAnnotations;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM