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.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public:
static bool CanConvert (
	String^ text, 
	ValidationDataType type
)
public static boolean CanConvert (
	String text, 
	ValidationDataType type
)
public static function CanConvert (
	text : String, 
	type : ValidationDataType
) : boolean
Not applicable.

Parameters

text

The string to test.

type

One of the ValidationDataType values.

Return Value

true 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.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: