This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16998|Reply: 1

[ASP.NET] MVC Data Validation

[Copy link]
Posted on 6/28/2015 10:25:36 AM | | |
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.ComponentModel.DataAnnotations;

  6. namespace MvcApplication1.Models
  7. {
  8. publicclass UserModel
  9. {
  10. publicstring Name { get; set; }


  11. //属性前加上Attribute
  12. [DisplayName("密码")]
  13. [Required(ErrorMessage ="密码不能为空")]
  14. [StringLength(20, ErrorMessage ="密码长度不能超过20个字符")]
  15. publicstring Password { get; set; }
  16. }
  17. }
Copy code






Previous:Based on Sina@ function simple example
Next:VS2010 Web Application Project XX is configured to use IIS. IIS Web Server is not installed on this computer
Posted on 6/29/2015 4:39:32 PM |
learned
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com