ValidatorCollection 类

定义

公开一个 IValidator 引用数组。Exposes an array of IValidator references. 此类不能被继承。This class cannot be inherited.

public ref class ValidatorCollection sealed : System::Collections::ICollection
public sealed class ValidatorCollection : System.Collections.ICollection
type ValidatorCollection = class
    interface ICollection
    interface IEnumerable
Public NotInheritable Class ValidatorCollection
Implements ICollection
继承
ValidatorCollection
实现

示例

下面的代码示例演示如何通过Page.Validators属性访问集合, 并GetEnumerator使用方法循环访问这些值。The following code example demonstrates how to access the collection through the Page.Validators property and use the GetEnumerator method to iterate through the values.

// Get 'Validators' of the page to myCollection.
ValidatorCollection myCollection = Page.Validators;

// Get the Enumerator.
IEnumerator myEnumerator = myCollection.GetEnumerator();
// Print the values in the ValidatorCollection.
string myStr = " ";
while ( myEnumerator.MoveNext() )
{
   myStr += myEnumerator.Current.ToString();
   myStr += " ";
}
messageLabel.Text = myStr;
' Get 'Validators' of the page to myCollection.
Dim myCollection As ValidatorCollection = Page.Validators
' Get the Enumerator.
Dim myEnumerator As IEnumerator = myCollection.GetEnumerator()
' Print the values in the ValidatorCollection.
Dim myStr As String = " "
While myEnumerator.MoveNext()
   myStr += myEnumerator.Current.ToString()
   myStr += " "
End While
messageLabel.Text = myStr

注解

ValidatorCollection个引用都与所请求的页上包含的验证服务器控件相关联。Each ValidatorCollection reference is associated with a validation server control contained on the requested page. 当处理Init Page对象的事件时, 这些控件将自身添加到此集合。These controls add themselves to this collection when the Init event of the Page object is handled. 当处理Unload Page对象的事件时, 它们会自行删除。They remove themselves when the Unload event of the Page object is handled. PageControl从类继承这两种方法。The Page class inherits both of these methods from the Control class.

可以通过Page.Validators属性访问此集合、其方法和属性。You can access this collection, its methods, and its properties through the Page.Validators property. 如果此集合中的任何验证器的测试条件都失败Page.IsValid , 则将属性false设置为。If the tested condition of any validator in this collection fails, the Page.IsValid property is set to false.

构造函数

ValidatorCollection()

初始化 ValidatorCollection 类的新实例。Initializes a new instance of the ValidatorCollection class.

属性

Count

获取集合中引用的数目。Gets the number of references in the collection.

IsReadOnly

获取一个值,该值指示 ValidatorCollection 集合是否是只读的。Gets a value that indicates whether the ValidatorCollection collection is read-only.

IsSynchronized

获取一个值,该值指示 ValidatorCollection 集合是否同步。Gets a value that indicates whether the ValidatorCollection collection is synchronized.

Item[Int32]

获取 ValidatorCollection 集合中位于指定索引位置的验证服务器控件。Gets the validation server control at the specified index location in the ValidatorCollection collection.

SyncRoot

获取一个对象,该对象可用于同步 ValidatorCollection 集合。Gets an object that can be used to synchronize the ValidatorCollection collection.

方法

Add(IValidator)

将指定的验证服务器控件添加到 ValidatorCollection 集合。Adds the specified validation server control to the ValidatorCollection collection.

Contains(IValidator)

确定指定的验证服务器控件是否包含在页的 ValidatorCollection 集合内。Determines whether the specified validation server control is contained within the page's ValidatorCollection collection.

CopyTo(Array, Int32)

从指定位置开始,将验证程序集合复制到指定数组。Copies the validator collection to the specified array, beginning at the specified location.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

返回 IEnumerator 集合的 ValidatorCollection 实例。Returns an IEnumerator instance for the ValidatorCollection collection.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Remove(IValidator)

从页的 ValidatorCollection 集合移除指定的验证服务器控件。Removes the specified validation server control from the page's ValidatorCollection collection.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅