开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜