System.Web.UI.WebControls.BaseCompareValidator.CanConvert Method

Determines whether the specified string can be converted to the specified data type. This version of the overloaded method tests currency, double, and date values using the format used by the current culture.

Syntax

public static bool CanConvert (string text, ValidationDataType type)

Parameters

text
The string to test.
type
One of the System.Web.UI.WebControls.ValidationDataType values.

Returns

true if the specified data string can be converted to the specified data type; otherwise, false.

Remarks

Use the BaseCompareValidator.CanConvert(string, ValidationDataType) method to determine whether the specified string can be converted to the specified data type. This method is commonly used to test whether a string can be converted to a compatible data type before performing an operation that depends on that data type.

This version of the method tests the value using the format used by the current culture. To test the value using a culture-neutral format, use the BaseCompareValidator.CanConvert(string, ValidationDataType, bool) overloaded version of this method.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0