CompareAttribute Class

 

Note: This API is now obsolete.

Provides an attribute that compares two properties of a model.

Namespace:   System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Inheritance Hierarchy

System.Object
  System.Attribute
    System.ComponentModel.DataAnnotations.ValidationAttribute
      System.Web.Mvc.CompareAttribute

Syntax

[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 : ValidationAttribute, IClientValidatable
[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 ref class CompareAttribute : ValidationAttribute, IClientValidatable
[<ObsoleteAttribute("The recommended alternative is to use the System.ComponentModel.DataAnnotations.CompareAttribute type, which has the same functionality as this type.")>]
[<AttributeUsageAttribute(AttributeTargets.Property)>]
type CompareAttribute = 
    class
        inherit ValidationAttribute
        interface IClientValidatable
    end
<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

Constructors

Name Description
System_CAPS_pubmethod CompareAttribute(String)

Initializes a new instance of the CompareAttribute class.

Properties

Name Description
System_CAPS_pubproperty ErrorMessage

(Inherited from ValidationAttribute.)

System_CAPS_pubproperty ErrorMessageResourceName

(Inherited from ValidationAttribute.)

System_CAPS_pubproperty ErrorMessageResourceType

(Inherited from ValidationAttribute.)

System_CAPS_protproperty ErrorMessageString

(Inherited from ValidationAttribute.)

System_CAPS_pubproperty OtherProperty

Gets the property to compare with the current property.

System_CAPS_pubproperty OtherPropertyDisplayName

Gets the other properties display name.

System_CAPS_pubproperty RequiresValidationContext

(Inherited from ValidationAttribute.)

System_CAPS_pubproperty TypeId

(Inherited from Attribute.)

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Attribute.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod FormatErrorMessage(String)

Applies formatting to an error message based on the data field where the compare error occurred.(Overrides ValidationAttribute.FormatErrorMessage(String).)

System_CAPS_pubmethodSystem_CAPS_static FormatPropertyForClientValidation(String)

Formats the property for client validation by prepending an asterisk (*) and a dot.

System_CAPS_pubmethod GetClientValidationRules(ModelMetadata, ControllerContext)

Gets a list of compare-value client validation rules for the property using the specified model metadata and controller context.

System_CAPS_pubmethod GetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod GetValidationResult(Object, ValidationContext)

(Inherited from ValidationAttribute.)

System_CAPS_pubmethod IsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethod IsValid(Object)

(Inherited from ValidationAttribute.)

System_CAPS_protmethod IsValid(Object, ValidationContext)

Determines whether the specified object is equal to the compared object.(Overrides ValidationAttribute.IsValid(Object, ValidationContext).)

System_CAPS_pubmethod Match(Object)

(Inherited from Attribute.)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

System_CAPS_pubmethod Validate(Object, String)

(Inherited from ValidationAttribute.)

System_CAPS_pubmethod Validate(Object, ValidationContext)

(Inherited from ValidationAttribute.)

Explicit Interface Implementations

Name Description
System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetTypeInfoCount(UInt32)

(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

(Inherited from Attribute.)

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

System.Web.Mvc Namespace

Return to top