CompareAttribute Class
Provides an attribute that compares two properties of a model.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
System.Attribute
System.ComponentModel.DataAnnotations.ValidationAttribute
System.Web.Mvc.CompareAttribute
<ObsoleteAttribute("The recommended alternative is to use the System.ComponentModel.DataAnnotations.CompareAttribute type, which has the same functionality as this type.")> <AttributeUsageAttribute(AttributeTargets.Property)> Public Class CompareAttribute Inherits ValidationAttribute Implements IClientValidatable
| Name | Description | |
|---|---|---|
![]() | CompareAttribute(String) | Initializes a new instance of the CompareAttribute class. |
| Name | Description | |
|---|---|---|
![]() | ErrorMessage | (Inherited from ValidationAttribute.) |
![]() | ErrorMessageResourceName | (Inherited from ValidationAttribute.) |
![]() | ErrorMessageResourceType | (Inherited from ValidationAttribute.) |
![]() | ErrorMessageString | (Inherited from ValidationAttribute.) |
![]() | OtherProperty | Gets the property to compare with the current property. |
![]() | OtherPropertyDisplayName | Gets the other properties display name. |
![]() | RequiresValidationContext | (Inherited from ValidationAttribute.) |
![]() | TypeId | (Inherited from Attribute.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | (Inherited from Attribute.) |
![]() | Finalize() | (Inherited from Object.) |
![]() | FormatErrorMessage(String) | Applies formatting to an error message based on the data field where the compare error occurred.(Overrides ValidationAttribute.FormatErrorMessage(String).) |
![]() ![]() | FormatPropertyForClientValidation(String) | Formats the property for client validation by prepending an asterisk (*) and a dot. |
![]() | GetClientValidationRules(ModelMetadata, ControllerContext) | Gets a list of compare-value client validation rules for the property using the specified model metadata and controller context. |
![]() | GetHashCode() | (Inherited from Attribute.) |
![]() | GetType() | (Inherited from Object.) |
![]() | GetValidationResult(Object, ValidationContext) | (Inherited from ValidationAttribute.) |
![]() | IsDefaultAttribute() | (Inherited from Attribute.) |
![]() | IsValid(Object) | (Inherited from ValidationAttribute.) |
![]() | IsValid(Object, ValidationContext) | Determines whether the specified object is equal to the compared object.(Overrides ValidationAttribute.IsValid(Object, ValidationContext).) |
![]() | Match(Object) | (Inherited from Attribute.) |
![]() | MemberwiseClone() | (Inherited from Object.) |
![]() | ToString() | (Inherited from Object.) |
![]() | Validate(Object, String) | (Inherited from ValidationAttribute.) |
![]() | Validate(Object, ValidationContext) | (Inherited from ValidationAttribute.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute.GetTypeInfoCount(UInt32) | (Inherited from Attribute.) |
![]() ![]() | _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | (Inherited from Attribute.) |
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.






