customvalidator onServerValidate 未触发

发布于 2024-10-02 06:26:04 字数 884 浏览 0 评论 0原文

我有一个单选按钮列表和文本框都带有验证。

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送你一个梦 2024-10-09 06:26:04

您是否在代码后面的某处调用 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文