System.Configuration Namesp ...


.NET Framework Class Library
CallbackValidatorAttribute Class

Specifies a CallbackValidator object to use for code validation. This class cannot be inherited.

Namespace:  System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
Syntax

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Property)> _
Public NotInheritable Class CallbackValidatorAttribute _
    Inherits ConfigurationValidatorAttribute
Visual Basic (Usage)
Dim instance As CallbackValidatorAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Property)]
public sealed class CallbackValidatorAttribute : ConfigurationValidatorAttribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Property)]
public ref class CallbackValidatorAttribute sealed : public ConfigurationValidatorAttribute
JScript
public final class CallbackValidatorAttribute extends ConfigurationValidatorAttribute
Remarks

The CallbackValidatorAttribute attribute class provides an association between a CallbackValidator object and the code to validate. The CallbackValidatorAttribute class is derived from the ConfigurationValidatorAttribute class.

Inheritance Hierarchy

System..::.Object
  System..::.Attribute
    System.Configuration..::.ConfigurationValidatorAttribute
      System.Configuration..::.CallbackValidatorAttribute
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Tags :


Community Content

Will Sullivan
How to use

The documentation on using this is pretty sketchy.

To use, you must first set the Type and MethodName thusly


[CallbackValidator(Type=typeof(MyValidatorClass), CallbackMethodName="MyValidatorMethodName")]

The class MyValidatorClass must have a public, static method called MyValidatorMethodName. This method must take exactly one argument and it must be of type System.Object. It must return void.

Within the MyValidatorMethodName, you should examine the object passed to see if it passes your validation tests. For instance, you might check an employee id against the database to make sure it is valid.

If validation succeeds, your method should simply return. If it fails, your method should throw an ArgumentException, or another exception of a relevant type.


Page view tracker