Delen via


CompareAttribute Class

Definition

Caution

The recommended alternative is to use the System.ComponentModel.DataAnnotations.CompareAttribute type, which has the same functionality as this type.

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
CompareAttribute
Attributes
Implements

Constructors

CompareAttribute(String)

Initializes a new instance of the CompareAttribute class.

Properties

OtherProperty

Gets the property to compare with the current property.

OtherPropertyDisplayName

Gets the other properties display name.

Methods

FormatErrorMessage(String)

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

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.

IsValid(Object, ValidationContext)

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

Applies to