共用方式為


ValidationRuleRequiredAttributeValue.MatchAttributeName 屬性

取得或設定其他屬性名稱,這個名稱必須位於包含要驗證之屬性值的 HTML 標記中。 搭配 MatchAttributeValue 使用。

命名空間:  Microsoft.VisualStudio.TestTools.WebTesting.Rules
組件:  Microsoft.VisualStudio.QualityTools.WebTestFramework (在 Microsoft.VisualStudio.QualityTools.WebTestFramework.dll 中)

語法

'宣告
Public Property MatchAttributeName As String
    Get
    Set
public string MatchAttributeName { get; set; }
public:
property String^ MatchAttributeName {
    String^ get ();
    void set (String^ value);
}
member MatchAttributeName : string with get, set
function get MatchAttributeName () : String
function set MatchAttributeName (value : String)

屬性值

型別:System.String
屬性名稱。

備註

這個屬性 (Property) (搭配 MatchAttributeValue) 會提供指定要驗證之屬性 (Attribute) 的其他資訊。

假設有下列 HTML:

<input name="Name" type="text" id="TextBox1" size="25" />

<input name="Email" type="text" id="TextBox2" size="25" />

<input name="Password" type="password" id="TextBox3" size="25" />

您會想要驗證可供使用者輸入密碼的輸入方塊存在,並且基於安全性,驗證輸入類型為密碼。

注意事項注意事項

文字輸入會在使用者輸入時顯示字母,而密碼輸入會在使用者輸入時顯示 *。

若要這樣做,請將 TagName 屬性設定為 input、將 AttributeName 屬性設定為 type,並將 ExpectedValue 屬性設定為 password。

請注意,HTML 中的三個標記都是 input 標記,而且包含 type 屬性。 若要驗證正確標記中的屬性,您必須提供其他資訊。 將 MatchAttributeName 屬性設定為 name,並將 MatchAttributeValue 屬性設定為 Password。 如此,只有一個標記會滿足指定的準則,而且屬性驗證規則將會套用至該標記。

.NET Framework 安全性

請參閱

參考

ValidationRuleRequiredAttributeValue 類別

Microsoft.VisualStudio.TestTools.WebTesting.Rules 命名空間