Exemple #1
0
        private DateTimeValidator CreateTypeIsDateTimeValidator(IResourceManager resourceManager)
        {
            DateTimeValidator typeValidator = new DateTimeValidator();

            typeValidator.ID = ID + "_ValidatorType";
            typeValidator.ControlToValidate = TargetControl.ID;
            if (string.IsNullOrEmpty(ErrorMessage))
            {
                typeValidator.ErrorMessage = resourceManager.GetString(ResourceIdentifier.InvalidDateAndTimeErrorMessage);
            }
            else
            {
                typeValidator.ErrorMessage = ErrorMessage;
            }
            return(typeValidator);
        }
Exemple #2
0
        public static BaseValidator[] CreateValidators(BocTextValue textValueControl, string baseID)
        {
            ArrayList validators = new ArrayList();

            if (textValueControl.IsRequired)
            {
                RequiredFieldValidator requiredValidator = new RequiredFieldValidator();
                requiredValidator.ID = baseID + "Required";
                requiredValidator.ControlToValidate = textValueControl.TargetControl.ID;
                requiredValidator.ErrorMessage      = "Enter a value.";
                requiredValidator.Display           = ValidatorDisplay.Dynamic;
                validators.Add(requiredValidator);
            }

            BocTextValueType valueType = textValueControl.ActualValueType;

            if (valueType == BocTextValueType.DateTime)
            {
                DateTimeValidator typeValidator = new DateTimeValidator();
                typeValidator.ID = baseID + "Type";
                typeValidator.ControlToValidate = textValueControl.TargetControl.ID;
                typeValidator.ErrorMessage      = "Wrong type.";
                typeValidator.Display           = ValidatorDisplay.Dynamic;
                validators.Add(typeValidator);
            }
            else if (valueType != BocTextValueType.Undefined && valueType != BocTextValueType.String)
            {
                CompareValidator typeValidator = new CompareValidator();
                typeValidator.ID = baseID + "Type";
                typeValidator.ControlToValidate = textValueControl.TargetControl.ID;
                typeValidator.Operator          = ValidationCompareOperator.DataTypeCheck;
                typeValidator.Type         = GetValidationDataType(valueType);
                typeValidator.ErrorMessage = "Wrong type.";
                typeValidator.Display      = ValidatorDisplay.Dynamic;
                //typeValidator.EnableClientScript = false;
                validators.Add(typeValidator);
            }

            return((BaseValidator[])validators.ToArray(typeof(BaseValidator)));
        }