BaseCompareValidator.Compare Method

Definition

Compares two strings using the specified operator and validation data type.

Overloads

Compare(String, String, ValidationCompareOperator, ValidationDataType)

Compares two strings using the specified operator and data type. This version of the overloaded method compares currency, double, and date values using the format used by the current culture.

Compare(String, Boolean, String, Boolean, ValidationCompareOperator, ValidationDataType)

Compares two strings using the specified operator and validation data type. This version of the overload allows you to specify whether values are compared using a culture-neutral format.

Compare(String, String, ValidationCompareOperator, ValidationDataType)

Compares two strings using the specified operator and data type. This version of the overloaded method compares currency, double, and date values using the format used by the current culture.

protected:
 static bool Compare(System::String ^ leftText, System::String ^ rightText, System::Web::UI::WebControls::ValidationCompareOperator op, System::Web::UI::WebControls::ValidationDataType type);
protected static bool Compare (string leftText, string rightText, System.Web.UI.WebControls.ValidationCompareOperator op, System.Web.UI.WebControls.ValidationDataType type);
static member Compare : string * string * System.Web.UI.WebControls.ValidationCompareOperator * System.Web.UI.WebControls.ValidationDataType -> bool
Protected Shared Function Compare (leftText As String, rightText As String, op As ValidationCompareOperator, type As ValidationDataType) As Boolean

Parameters

leftText
String

The value on the left side of the operator.

rightText
String

The value on the right side of the operator.

type
ValidationDataType

One of the ValidationDataType values.

Returns

true if the leftValue parameter relates to the rightValue parameter in the manner specified by the op parameter; otherwise, false.

Remarks

The Compare(String, String, ValidationCompareOperator, ValidationDataType) method is used to test whether the value of the leftText parameter relates to the value of the rightText parameter in the manner specified by the op parameter. The type parameter specifies the data type of the values being compared.

Note

If the op parameter is set to ValidationCompareOperator.DataTypeCheck, this method tests only the value of the leftText parameter for the data type specified by the type parameter. The rightText parameter is ignored.

This version of the method compares the values using the format used by the current culture. To compare the values using a culture-neutral format, use the BaseCompareValidator.Compare(String, Boolean, String, Boolean, ValidationCompareOperator, ValidationDataType) overloaded version of this method.

See also

Applies to

Compare(String, Boolean, String, Boolean, ValidationCompareOperator, ValidationDataType)

Compares two strings using the specified operator and validation data type. This version of the overload allows you to specify whether values are compared using a culture-neutral format.

protected:
 static bool Compare(System::String ^ leftText, bool cultureInvariantLeftText, System::String ^ rightText, bool cultureInvariantRightText, System::Web::UI::WebControls::ValidationCompareOperator op, System::Web::UI::WebControls::ValidationDataType type);
protected static bool Compare (string leftText, bool cultureInvariantLeftText, string rightText, bool cultureInvariantRightText, System.Web.UI.WebControls.ValidationCompareOperator op, System.Web.UI.WebControls.ValidationDataType type);
static member Compare : string * bool * string * bool * System.Web.UI.WebControls.ValidationCompareOperator * System.Web.UI.WebControls.ValidationDataType -> bool
Protected Shared Function Compare (leftText As String, cultureInvariantLeftText As Boolean, rightText As String, cultureInvariantRightText As Boolean, op As ValidationCompareOperator, type As ValidationDataType) As Boolean

Parameters

leftText
String

The value on the left side of the operator.

cultureInvariantLeftText
Boolean

true to convert the left side value to a culture-neutral format; otherwise, false.

rightText
String

The value on the right side of the operator.

cultureInvariantRightText
Boolean

true to convert the right side value to a culture-neutral format; otherwise, false.

type
ValidationDataType

One of the ValidationDataType values.

Returns

true if the leftValue parameter relates to the rightValue parameter in the manner specified by the op parameter; otherwise, false.

Remarks

The Compare(String, Boolean, String, Boolean, ValidationCompareOperator, ValidationDataType) method is used to test whether the value of the leftText parameter relates to the value of the rightText parameter in the manner specified by the op parameter. The type parameter specifies the data type of the values being compared.

Note

If the op parameter is set to ValidationCompareOperator.DataTypeCheck, this method tests only the value of the leftText parameter for the data type specified by the type parameter. The rightText parameter is ignored.

To indicate that values should be compared using a culture-neutral format, pass in true for the cultureInvariantLeftText and cultureInvariantRightText parameters; otherwise, the values are compared using the format used by the current culture. When comparing values using the format used by the current culture, consider using the BaseCompareValidator.Compare(String, String, ValidationCompareOperator, ValidationDataType) overloaded version of this method.

See also

Applies to