简体   繁体   中英

Validation Group in ASP.NET 1.1

I have 2 buttons which validates different sets of textboxes (which have corresponding asp validators). How can I control the validations triggered by each button?

将ValidationGroup =“ set1”和ValidationGroup =“ set2”属性添加到您应该执行的文本框,按钮,验证器和验证摘要中。

You have to set the same Group name for each set of textbox and buttons .

<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="GroupOne"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"         
ControlToValidate="TextBox1"
ErrorMessage="ErrorMessageForTextBox1" ValidationGroup="GroupOne">   
</asp:RequiredFieldValidator>  

<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="GroupOne" />

<asp:TextBox ID="TextBox2" runat="server" ValidationGroup="GroupTwo"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"        
ControlToValidate="TextBox2"
ErrorMessage="ErrorMessageForTextBox1" ValidationGroup="GroupTwo">   
</asp:RequiredFieldValidator>

For ASP version 1.1 , use this link !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM