BaseCompareValidator::CanConvert Method (String, ValidationDataType)
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.
Assembly: System.Web (in System.Web.dll)
Parameters
- text
- Type: System::String
The string to test.
- type
- Type: System.Web.UI.WebControls::ValidationDataType
One of the ValidationDataType values.
Return Value
Type: System::Booleantrue if the specified data string can be converted to the specified data type; otherwise, false.
Use the 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, Boolean) overloaded version of this method.
The following example demonstrates using the CanConvert method to compare two integer values and determine whether the second integer can be converted.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.