Link to home
Start Free TrialLog in
Avatar of solution1368
solution1368

asked on

asp.net, wizard, validation control

Just try to write a code for a simple validator in asp.net inside of the asp.net wizard.
However, it does not fire up...any one knows why?


<asp:CheckBox runat="server" ID="StuntActivityStunt"  Text="Stunts" />

<asp:CustomValidator runat="server"
 ID="CustomValidatorStuntActivityStunt"  ForeColor="Red" Font-Bold="true"
 OnServerValidate="CustomValidatorStuntActivityStunt_ServerValidate"></asp:CustomValidator>



 protected void CustomValidatorStuntActivityStunt_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (this.StuntActivityStunt.Checked)
            {
                args.IsValid = false;
                CustomValidatorStuntActivityStunt.ErrorMessage = "Something Wrong";
            }
        }
Avatar of Kumaraswamy R
Kumaraswamy R
Flag of India image

protected void CustomValidatorStuntActivityStunt_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if    ( ! this.StuntActivityStunt.Checked)
        {
            args.IsValid = false;
            CustomValidatorStuntActivityStunt.ErrorMessage = "Something Wrong";
        }
    }

add in the if Not condition , because of, if not checked it return false
ASKER CERTIFIED SOLUTION
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial