<asp:RadioButtonList ID="isXd" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
            <asp:ListItem Value="1">价格相等</asp:ListItem>
            <asp:ListItem Value="0">价格不相等</asp:ListItem>
        </asp:RadioButtonList>
        asp:CustomValidator ID="cv_isxd" runat="server" ControlToValidate="isXd"
            Display="Dynamic" ErrorMessage="*请选择价格是否相等!" OnServerValidate="cv_isxd_ServerValidate"></asp:CustomValidator>
            protected void cv_isxd_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (args.Value == null || args.Value == "")
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }
不起作用,各位高手帮帮忙检查一下。看哪个地方弄错了

解决方案 »

  1.   

    这你个是事件吧,要激发事件,就会有安扭,你有一个验证控件,就会阻止事件发生。
    有两种方法
    1,要激发事件的控件。加上,CausesValidation="False",不激发给证2<asp:RadioButtonList ID="isXd" 和asp:CustomValidator ID="cv_isxd" 这两个控件都同时加上这个
    ValidationGroup="1" 1是乱写的,你可以写其它什么都行,但,都要一样。就是将那两个控件分成一组。验证只对组内成员有效。