本文介绍了用于在mvc4中的同一视图上插入和显示记录的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的模特 public class tbl_EmpRegistrationEntites { public global :: System。 Int32 EmpId { get ; set ; } [必需(ErrorMessage = 请输入Emailid)] // [DataType(DataType.EmailAddress)] [ RegularExpression( @ ^([a-zA-Z0-9_ \-\。] +)@(( \ [[0-9] {1,3} \ [0-9] {1,3} \ [0-9] {1,3} \)|。。。(([A-ZA -Z0-9\ - ] + \)+))([A-ZA-Z] {2,4} |。?[0-9] {1,3})(\])$,ErrorMessage = 输入有效的电子邮件地址)] public global :: System。 String EmailId { get ; set ; } [必需(ErrorMessage = 请输入密码)] [DataType(DataType.Password)] [StringLength( 50 ,ErrorMessage = {0}长度必须至少为{2}个字符。,MinimumLength = 6 )] public global :: System。字符串密码 { get ; set ; } [必需(ErrorMessage = 请输入CompanyName)] [StringLength( 400 ,ErrorMessage = Maximaum长度为400个字符)] public global :: System。 String CompanyName { get ; set ; } [必需(ErrorMessage = 请输入CompanyType)] [StringLength( 50 ,ErrorMessage = Maximaum长度为50个字符)] public global :: System。 String CompanyType { get ; set ; } [显示(名称= IndustryType) ] [必需(ErrorMessage = 请选择IndustryType)] public global :: System。 Int32 IndustryTypeId { get ; set ; } [必需(ErrorMessage = 请输入地址)] [StringLength( 400 ,ErrorMessage = Maximaum长度为400个字符)] public global :: System。 String 地址 { get ; set ; } [显示(名称= 国家) ] [必需(ErrorMessage = 请选择国家)] public global :: System。 Int32 CountId { get ; set ; } [显示(名称= 状态) ] [必需(ErrorMessage = 请选择州)] public global :: System。 Int32 StateId { get ; set ; } [显示(名称= 城市) ] [必需(ErrorMessage = 请选择城市)] public global :: System。 Int32 CityId { get ; set ; } [必需(ErrorMessage = 请选择邮政编码)] // [RegularExpression(@^(\\\ {6})$, ErrorMessage =只有6位数字Pincode编号。)] public 全球 :: System。 String PinCode { get ; set ; } [必需(ErrorMessage = 请输入MobileNo)] // [RegularExpression(@^(\\\ {10})$, ErrorMessage =仅10位数字移动电话号码)) public global :: System。 String MobileNo { get ; set ; } public global :: System 。布尔 IsActive { get ; set ; } } 解决方案 ,ErrorMessage = 输入有效的电子邮件地址)] public global :: System。 String EmailId { get ; set ; } [必需(ErrorMessage = 请输入密码)] [DataType(DataType.Password)] [StringLength( 50 ,ErrorMessage = {0}长度必须至少为{2}个字符。,MinimumLength = 6 )] public global :: System。 String 密码 { 获得; set ; } [必需(ErrorMessage = 请输入CompanyName)] [StringLength( 400 ,ErrorMessage = Maximaum长度为400个字符)] public global :: System。 String CompanyName { get ; set ; } [必需(ErrorMessage = 请输入CompanyType)] [StringLength( 50 ,ErrorMessage = Maximaum长度为50个字符)] public global :: System。 String CompanyType { get ; set ; } [显示(名称= IndustryType) ] [必需(ErrorMessage = 请选择IndustryType)] public global :: System。 Int32 IndustryTypeId { get ; set ; } [必需(ErrorMessage = 请输入地址)] [StringLength( 400 ,ErrorMessage = Maximaum长度为400个字符)] public global :: System。 String 地址 { get ; set ; } [显示(名称= 国家) ] [必需(ErrorMessage = 请选择国家)] public global :: System。 Int32 CountId { get ; set ; } [显示(名称= 状态) ] [必需(ErrorMessage = 请选择州)] public global :: System。 Int32 StateId { get ; set ; } [显示(名称= 城市) ] [必需(ErrorMessage = 请选择城市)] public global :: System。 Int32 CityId { get ; set ; } [必需(ErrorMessage = 请选择邮政编码)] // [RegularExpression(@^(\d {6}) ,ErrorMessage =只有6位数字Pincode编号。] public global :: System。 String PinCode { 获得; set ; } [必需(ErrorMessage = 请输入MobileNo)] // [RegularExpression(@^(\d {10}) ,ErrorMessage =只有10位数字手机号码)) public global :: System。 String MobileNo { get ; set ; } public global :: System 。布尔 IsActive { get ; set ; } } my model public class tbl_EmpRegistrationEntites { public global::System.Int32 EmpId { get; set; } [Required(ErrorMessage = "Please Enter Emailid")] //[DataType (DataType.EmailAddress)] [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Enter valid email address")] public global::System.String EmailId { get; set; } [Required(ErrorMessage = "Please Enter Password")] [DataType(DataType.Password)] [StringLength(50,ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] public global::System.String Password { get; set; } [Required(ErrorMessage = "Please Enter CompanyName")] [StringLength(400, ErrorMessage = "The Maximaum length is 400 character")] public global::System.String CompanyName { get; set; } [Required(ErrorMessage = "Please Enter CompanyType")] [StringLength(50, ErrorMessage = "The Maximaum length is 50 character")] public global::System.String CompanyType { get; set; } [Display(Name = "IndustryType")] [Required(ErrorMessage = "Please Select IndustryType")] public global::System.Int32 IndustryTypeId { get; set; } [Required(ErrorMessage = "Please Enter Address")] [StringLength(400, ErrorMessage = "The Maximaum length is 400 character")] public global::System.String Address { get; set; } [Display(Name = "Country")] [Required(ErrorMessage = "Please Select Country")] public global::System.Int32 CountId { get; set; } [Display(Name = "State")] [Required(ErrorMessage = "Please Select State")] public global::System.Int32 StateId { get; set; } [Display(Name = "City")] [Required(ErrorMessage = "Please Select City")] public global::System.Int32 CityId { get; set; } [Required(ErrorMessage = "Please Select Postcode")] //[RegularExpression(@"^(\d{6})$", ErrorMessage = "Only 6 Digit Pincode No.")] public global::System.String PinCode { get; set; } [Required(ErrorMessage = "Please Enter MobileNo")] //[RegularExpression(@"^(\d{10})$", ErrorMessage = "Only 10 Digit Mobile No.")] public global::System.String MobileNo { get; set; } public global::System.Boolean IsActive { get; set; } } 解决方案 ", ErrorMessage = "Enter valid email address")] public global::System.String EmailId { get; set; } [Required(ErrorMessage = "Please Enter Password")] [DataType(DataType.Password)] [StringLength(50,ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] public global::System.String Password { get; set; } [Required(ErrorMessage = "Please Enter CompanyName")] [StringLength(400, ErrorMessage = "The Maximaum length is 400 character")] public global::System.String CompanyName { get; set; } [Required(ErrorMessage = "Please Enter CompanyType")] [StringLength(50, ErrorMessage = "The Maximaum length is 50 character")] public global::System.String CompanyType { get; set; } [Display(Name = "IndustryType")] [Required(ErrorMessage = "Please Select IndustryType")] public global::System.Int32 IndustryTypeId { get; set; } [Required(ErrorMessage = "Please Enter Address")] [StringLength(400, ErrorMessage = "The Maximaum length is 400 character")] public global::System.String Address { get; set; } [Display(Name = "Country")] [Required(ErrorMessage = "Please Select Country")] public global::System.Int32 CountId { get; set; } [Display(Name = "State")] [Required(ErrorMessage = "Please Select State")] public global::System.Int32 StateId { get; set; } [Display(Name = "City")] [Required(ErrorMessage = "Please Select City")] public global::System.Int32 CityId { get; set; } [Required(ErrorMessage = "Please Select Postcode")] //[RegularExpression(@"^(\d{6})", ErrorMessage = "Only 6 Digit Pincode No.")] public global::System.String PinCode { get; set; } [Required(ErrorMessage = "Please Enter MobileNo")] //[RegularExpression(@"^(\d{10})", ErrorMessage = "Only 10 Digit Mobile No.")] public global::System.String MobileNo { get; set; } public global::System.Boolean IsActive { get; set; } } 这篇关于用于在mvc4中的同一视图上插入和显示记录的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 05:15