BaseCompareValidator.CanConvert Method (String, ValidationDataType, Boolean)

Note: This method is new in the .NET Framework version 2.0.

Determines whether the specified string can be converted to the specified data type. This version of the overloaded method allows you to specify whether values are tested using a culture-neutral format.

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

public:
static bool CanConvert (
	String^ text, 
	ValidationDataType type, 
	bool cultureInvariant
)
public static boolean CanConvert (
	String text, 
	ValidationDataType type, 
	boolean cultureInvariant
)
public static function CanConvert (
	text : String, 
	type : ValidationDataType, 
	cultureInvariant : boolean
) : boolean

Parameters

text

The string to test.

type

One of the ValidationDataType enumeration values.

cultureInvariant

true to test values using a culture-neutral format; otherwise, false.

Return Value

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

Use the CanConvert(String,ValidationDataType,Boolean) 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. To indicate that values should be tested using a culture-neutral format, pass in true for the cultureInvariant parameter; otherwise, values are tested using the format used by the current culture. When testing a value using the format used by the current culture, consider using the BaseCompareValidator.CanConvert(String,ValidationDataType) overloaded version of this method.

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: