customvalidator onServerValidate 未触发
我有一个单选按钮列表和文本框都带有验证。
<asp:RadioButtonList ID="member" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
<asp:requiredfieldvalidator id="unionvalidator" runat="server" controltovalidate="member" errormessage="Required" />
Required if member == "yes"
<asp:TextBox runat="server" ID="union"></asp:TextBox>
<asp:customvalidator ID="Customvalidator1" runat="server" ValidateEmptyText="true" onServerValidate="UnionValidate" errormessage="Your current union is required" />
我的 ServerValidate 根本不触发。
public void UnionValidate(object source, ServerValidateEventArgs args)
{
if (member.Text == "yes" && union.Text.Trim() == "")
args.IsValid = false;
}
I have a Radio button List and Text Box both with validation.
<asp:RadioButtonList ID="member" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
<asp:requiredfieldvalidator id="unionvalidator" runat="server" controltovalidate="member" errormessage="Required" />
Required if member == "yes"
<asp:TextBox runat="server" ID="union"></asp:TextBox>
<asp:customvalidator ID="Customvalidator1" runat="server" ValidateEmptyText="true" onServerValidate="UnionValidate" errormessage="Your current union is required" />
My ServerValidate which doesn't fire at all.
public void UnionValidate(object source, ServerValidateEventArgs args)
{
if (member.Text == "yes" && union.Text.Trim() == "")
args.IsValid = false;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在代码后面的某处调用 Page.Validate() 方法,或者提交按钮是否将 CausesValidation 设置为 true?
Are you calling the Page.Validate() method somewhere in your code behind or does the submit button has the CausesValidation set to true?