close

using System.ComponentModel.DataAnnotations;


public class Customer
    {

        public int CustomerID { get; set; }
        [Required(ErrorMessage = "你的名字是啥?快填!")]
        [Display(Name="名字")]
        public string FirstName { get; set; }
        [Required]
        [Display(Name = "姓")]
        public string LastName { get; set; }
        [Required]
        [StringLength(10,ErrorMessage="the company name must less than 10 characters!")]
        [Display(Name="公司名稱")]
        public string Company { get; set; }
        [Required]       
        public string Email { get; set; }

        [NotMapped]
        [Compare("Email", ErrorMessage = "Please enter the same email!")]
        public string EmailCheck { get; set; }

    }   

 

public class Product
    {
        public int ProductID { get; set; }
        [Required]
        public string Title { get; set; }
        [Required]
        public string Description { get; set; }
        [Range(0.0,5000.0,ErrorMessage="the range is between 0 and 5000!")]
        public double Price { get; set; }
    }

 

arrow
arrow
    文章標籤
    MVC3 欄位值驗證
    全站熱搜
    創作者介紹
    創作者 chilliwack425 的頭像
    chilliwack425

    無聊的部落格

    chilliwack425 發表在 痞客邦 留言(0) 人氣()