ValidatorCollection.Item[Int32] 属性

定义

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

public:
 property System::Web::UI::IValidator ^ default[int] { System::Web::UI::IValidator ^ get(int index); };
public System.Web.UI.IValidator this[int index] { get; }
member this.Item(int) : System.Web.UI.IValidator
Default Public ReadOnly Property Item(index As Integer) As IValidator

参数

index
Int32

要返回的验证程序的索引。The index of the validator to return.

属性值

IValidator

指定的验证程序的值。The value of the specified validator.

示例

下面的代码示例演示如何使用 Item[] 属性。The following code example demonstrates using the Item[] property.

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

// Print the values of Collection using 'Item' property.
string myStr = " ";         
for(int i = 0; i<myCollection.Count; i++)
{
   myStr += myCollection[i].ToString();
   myStr += " ";
}
msgLabel.Text = myStr;        
' Get 'Validators' of the page to myCollection.
Dim myCollection As ValidatorCollection = Page.Validators
' Print the values of Collection using 'Item' property.
Dim myStr As String = " "
Dim i As Integer
For i = 0 To myCollection.Count - 1
   myStr = mystr & CType(myCollection(i),BaseValidator).ToString() & "<br />"
Next i
msgLabel.Text = myStr

适用于

另请参阅