Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.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)
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

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.

System..::.Object
  System..::.Attribute
    System.Configuration..::.ConfigurationValidatorAttribute
      System.Configuration..::.CallbackValidatorAttribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
How to use      Will Sullivan   |   Edit   |   Show History

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.

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker