CompareAttribute CompareAttribute CompareAttribute Class

Definition

Warning

This API is now obsolete.

Provides an attribute that compares two properties of a model.

[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("The recommended alternative is to use the System.ComponentModel.DataAnnotations.CompareAttribute type, which has the same functionality as this type.")]
public class CompareAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute, System.Web.Mvc.IClientValidatable
type CompareAttribute = class
    inherit ValidationAttribute
    interface IClientValidatable
Public Class CompareAttribute
Inherits ValidationAttribute
Implements IClientValidatable
Inheritance
CompareAttributeCompareAttributeCompareAttribute
Attributes
Implements

Constructors

CompareAttribute(String) CompareAttribute(String) CompareAttribute(String)

Initializes a new instance of the CompareAttribute class.

Properties

OtherProperty OtherProperty OtherProperty

Gets the property to compare with the current property.

OtherPropertyDisplayName OtherPropertyDisplayName OtherPropertyDisplayName

Gets the other properties display name.

Methods

FormatErrorMessage(String) FormatErrorMessage(String) FormatErrorMessage(String)

Applies formatting to an error message based on the data field where the compare error occurred.

FormatPropertyForClientValidation(String) FormatPropertyForClientValidation(String) FormatPropertyForClientValidation(String)

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

GetClientValidationRules(ModelMetadata, ControllerContext) GetClientValidationRules(ModelMetadata, ControllerContext) GetClientValidationRules(ModelMetadata, ControllerContext)

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

IsValid(Object, ValidationContext) IsValid(Object, ValidationContext) IsValid(Object, ValidationContext)

Determines whether the specified object is equal to the compared object.

Applies to