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. 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 類別的新執行個體。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 的淺層複本 (Shallow Copy)。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()

傳回代表目前物件的字串。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.

適用於

另請參閱