Ejemplo n.º 1
0
        /// <summary>
        /// Sets the IsValid property to false, and marks the first control to validate
        /// as invalid.
        /// </summary>
        public void MarkInvalid()
        {
            IsValid = false;
            ArrayList ControlsToValidate = new ArrayList();

            ControlsToValidate.Reverse();
            ControlsToValidate.AddRange(ControlToValidate.Split(','));
            Control C = null;

            foreach (string st in ControlsToValidate)
            {
                C = FindControl(st);
                if (IsMarkedInvalid(C))
                {
                    return;
                }
            }
            ControlsToValidate.Reverse();
            foreach (string st in ControlsToValidate)
            {
                C = FindControl(st);
                if (MarkInvalid(C))
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if the validation event is true for all the controls listed
        /// in ControlToValidate.  Sets Validated to true when finished.
        /// </summary>
        /// <exception cref="ValidatorCircularException">
        /// Thrown if method is called recursively on the same object.  Means that
        /// one of the controls being validated is dependant on itself.  Could be
        /// through multiple levels.
        /// </exception>
        /// <exception cref="ValidatorNotDefinedException">
        /// Thrown if neither OnServerValidate property or ControlToValidate property
        /// is set.  At least one of the two must be set.  Default value will be used
        /// for OnServerValidate if only ControlToValidate is set.  This control will
        /// be supplied to OnServerValidate delegate if on OnServerValidate is set.
        /// </exception>
        protected override bool EvaluateIsValid()
        {
            if (Validated)
            {
                return(base.IsValid);
            }
            if (Validating)
            {
                throw new ValidatorCircularException(ID);
            }
            Validating = true;
            if (ControlToValidate.Length == 0)
            {
                if (ServerValidate == null)
                {
                    throw new ValidatorNotDefinedException(ID);
                }
                return(CompleteValidation(EvaluateIsValid(ID)));
            }
            else if (ServerValidate == null)
            {
                ServerValidate = new ValidatorEventHandler(DefaultOnServerValidate);
            }
            ArrayList ControlsToValidate = new ArrayList();

            ControlsToValidate.AddRange(ControlToValidate.Split(','));
            foreach (string st in ControlsToValidate)
            {
                if (Any == EvaluateIsValid(st))
                {
                    return(CompleteValidation(Any));
                }
            }
            return(CompleteValidation(!Any));
        }