requiredfield验证器阻止另一个表单提交

时间:2022-12-01 08:59:18

I have a page with many forms in panels and usercontrols, and a requiredfield validator I just added to one form is preventing all of my other forms from submitting. what's the rule that I'm not following?

我在面板和用户控件中有一个包含许多表单的页面,我刚刚添加到一个表单中的requiredfield验证器阻止我的所有其他表单提交。我不遵循的规则是什么?

2 个解决方案

#1


5  

Are you using ValidationGroups? Try assigning each control with a validation group as well as the validator that you want to use. Something like:

您使用的是ValidationGroups吗?尝试使用验证组以及要使用的验证器分配每个控件。就像是:

<asp:TextBox ID="txt1" ValidationGroup="Group1" ruant="server" />
<asp:RequiredFieldValidator ID="rfv1" ... ValidationGroup="Group1" />

Note, if a button doesn't specify a validation group it will validate all controls that aren't assigned to a validation group.

请注意,如果某个按钮未指定验证组,则它将验证未分配给验证组的所有控件。

#2


0  

You should be setting ValidationGroup property to a different value for each group of elements. Your validator's ValidationGroup must only be same with the control that submit its form.

您应该将ValidationGroup属性设置为每组元素的不同值。验证者的ValidationGroup必须与提交表单的控件相同。

#1


5  

Are you using ValidationGroups? Try assigning each control with a validation group as well as the validator that you want to use. Something like:

您使用的是ValidationGroups吗?尝试使用验证组以及要使用的验证器分配每个控件。就像是:

<asp:TextBox ID="txt1" ValidationGroup="Group1" ruant="server" />
<asp:RequiredFieldValidator ID="rfv1" ... ValidationGroup="Group1" />

Note, if a button doesn't specify a validation group it will validate all controls that aren't assigned to a validation group.

请注意,如果某个按钮未指定验证组,则它将验证未分配给验证组的所有控件。

#2


0  

You should be setting ValidationGroup property to a different value for each group of elements. Your validator's ValidationGroup must only be same with the control that submit its form.

您应该将ValidationGroup属性设置为每组元素的不同值。验证者的ValidationGroup必须与提交表单的控件相同。