我有 2 个按钮来验证不同的文本框集(具有相应的 asp 验证器)。如何控制每个按钮触发的验证?
问问题
318 次
2 回答
0
Add ValidationGroup="set1" and ValidationGroup="set2" properties to your textboxes, buttons, Validators and Validation Summaries, that should do it.
于 2013-07-03T06:38:06.760 回答
0
您必须为每组文本框和按钮设置相同的组名称。
<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>
对于 ASP 1.1 版,请使用此链接!
于 2013-07-03T06:40:34.560 回答