customvalidator onServerValidate not firing

Posted by Jamie on Stack Overflow See other posts from Stack Overflow or by Jamie
Published on 2010-11-16T02:48:28Z Indexed on 2010/12/27 20:53 UTC
Read the original article Hit count: 250

Filed under:
|

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;
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about customvalidator