ValidatorCollection ValidatorCollection ValidatorCollection ValidatorCollection Class


公開 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


下列程式碼範例示範如何存取透過集合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. Page類別會繼承這兩種方法從Control類別。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屬性設定為falseIf the tested condition of any validator in this collection fails, the Page.IsValid property is set to false.


ValidatorCollection() ValidatorCollection() ValidatorCollection() ValidatorCollection()

初始化 ValidatorCollection 類別的新執行個體。Initializes a new instance of the ValidatorCollection class.


Count Count Count Count

取得集合中的參考數。Gets the number of references in the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得值,這個值表示 ValidatorCollection 集合是否為唯讀。Gets a value that indicates whether the ValidatorCollection collection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

取得值,指出 ValidatorCollection 集合是否已同步化。Gets a value that indicates whether the ValidatorCollection collection is synchronized.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

ValidatorCollection 集合中的指定索引位置,取得驗證伺服器控制項。Gets the validation server control at the specified index location in the ValidatorCollection collection.

SyncRoot SyncRoot SyncRoot SyncRoot

取得可以用來同步 ValidatorCollection 集合的物件。Gets an object that can be used to synchronize the ValidatorCollection collection.


Add(IValidator) Add(IValidator) Add(IValidator) Add(IValidator)

將指定的驗證伺服器控制項加入至 ValidatorCollection 集合。Adds the specified validation server control to the ValidatorCollection collection.

Contains(IValidator) Contains(IValidator) Contains(IValidator) Contains(IValidator)

判斷指定的驗證伺服器控制項是否包含在頁面的 ValidatorCollection 集合中。Determines whether the specified validation server control is contained within the page's ValidatorCollection collection.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

將驗證程式集合複製到指定陣列中,從指定位置開始。Copies the validator collection to the specified array, beginning at the specified location.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回 IEnumerator 集合的 ValidatorCollection 執行個體。Returns an IEnumerator instance for the ValidatorCollection collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(IValidator) Remove(IValidator) Remove(IValidator) Remove(IValidator)

從頁面的 ValidatorCollection 集合中,移除指定的驗證伺服器控制項。Removes the specified validation server control from the page's ValidatorCollection collection.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.