customvalidator onServerValidate not firing
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 Ser开发者_如何学GoverValidate which doesn't fire at all.
public void UnionValidate(object source, ServerValidateEventArgs args)
{
if (member.Text == "yes" && union.Text.Trim() == "")
args.IsValid = false;
}
Are you calling the Page.Validate() method somewhere in your code behind or does the submit button has the CausesValidation set to true?
精彩评论