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

1 に答える 1

1

コードビハインドのどこかでPage.Validate()メソッドを呼び出していますか、それとも送信ボタンのCausesValidationがtrueに設定されていますか?

于 2010-12-27T20:52:47.917 に答える