AllowedValuesAttribute 类

定义

重要

此 API 不符合 CLS。

指定属性中应允许的值的列表。

public ref class AllowedValuesAttribute : System::ComponentModel::DataAnnotations::ValidationAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false)]
[System.CLSCompliant(false)]
public class AllowedValuesAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false)>]
[<System.CLSCompliant(false)>]
type AllowedValuesAttribute = class
    inherit ValidationAttribute
Public Class AllowedValuesAttribute
Inherits ValidationAttribute
继承
AllowedValuesAttribute
属性

构造函数

名称 说明
AllowedValuesAttribute(Object[])

初始化 AllowedValuesAttribute 类的新实例。

属性

名称 说明
ErrorMessage

获取或设置一条错误消息,以在验证失败时与验证控件相关联。

(继承自 ValidationAttribute)
ErrorMessageResourceName

获取或设置要使用的错误消息资源名称,以便在验证失败时查找 ErrorMessageResourceType 属性值。

(继承自 ValidationAttribute)
ErrorMessageResourceType

获取或设置在验证失败时用于错误消息查找的资源类型。

(继承自 ValidationAttribute)
ErrorMessageString

获取本地化的验证错误消息。

(继承自 ValidationAttribute)
RequiresValidationContext

获取一个值,该值指示属性是否需要验证上下文。

(继承自 ValidationAttribute)
TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)
Values

获取此属性允许的值列表。

方法

名称 说明
Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
FormatErrorMessage(String)

根据发生错误的数据字段,将格式应用于错误消息。

(继承自 ValidationAttribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
GetValidationResult(Object, ValidationContext)

检查指定的值是否对当前验证属性有效。

(继承自 ValidationAttribute)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否为派生类的默认值。

(继承自 Attribute)
IsValid(Object, ValidationContext)

验证与当前验证属性相关的指定值。

(继承自 ValidationAttribute)
IsValid(Object)

确定指定的对象是否有效。 (替代 IsValid(Object)

Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
Validate(Object, String)

验证指定的对象。

(继承自 ValidationAttribute)
Validate(Object, ValidationContext)

验证指定的对象。

(继承自 ValidationAttribute)

适用于