campare属性出错 [英] error with campare attribute
本文介绍了campare属性出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我首先使用的是vs2012和mvc3。
但是比较属性有什么问题。我写了下面的代码。
I am first using vs2012 and mvc3.
but what's the problem with compare attribute. I wrote the following code.
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
,标题包含:
and the heading contain :
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
DataType和Display属性没有问题,但是比较属性有什么问题。
SHOUTING已删除 - OriginalGriff [/ edit]
There is no problem with DataType and Display attribute, but what wrong with compare attribute.
[edit]SHOUTING removed - OriginalGriff[/edit]
推荐答案
请尝试如下。使用 CompareAttribute 。
< b>注意:这只是一个示例。根据您的应用调整它。 :)
Please try is as below.Use CompareAttribute.
Note:This is just a sample.Adjust it according to your app. :)
public string EmailAddress {get; set;}
[CompareAttribute("EmailAddress", ErrorMessage = "Emails mismatch")]
public string VerifiedEmailAddress { get; set; }
点击此处查看更多信息: CompareAttribute
这篇关于campare属性出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文