예제 #1
0
        /// <summary> Creates the list of validators required for the current binding and property settings. </summary>
        /// <param name="isReadOnly">
        /// This flag is initialized with the value of <see cref="BusinessObjectBoundEditableWebControl.IsReadOnly"/>.
        /// Implemantations should consider whether they require a validator also when the control is rendered as read-only.
        /// </param>
        /// <remarks>
        ///   Generates a <see cref="BocDateTimeValueValidator"/> if the control is in edit mode.
        /// </remarks>
        /// <seealso cref="BusinessObjectBoundEditableWebControl.CreateValidators()">BusinessObjectBoundEditableWebControl.CreateValidators()</seealso>
        protected override IEnumerable <BaseValidator> CreateValidators(bool isReadOnly)
        {
            _dateTimeValidator = null;
            if (isReadOnly)
            {
                yield break;
            }

            _dateTimeValidator = CreateDateTimeValidator();
            yield return(_dateTimeValidator);
        }
예제 #2
0
        private BocDateTimeValueValidator CreateDateTimeValidator()
        {
            BocDateTimeValueValidator dateTimeValueValidator = new BocDateTimeValueValidator();

            dateTimeValueValidator.ID = ID + "_ValidatorDateTime";
            dateTimeValueValidator.ControlToValidate = ID;
            if (string.IsNullOrEmpty(_errorMessage))
            {
                IResourceManager resourceManager = GetResourceManager();
                dateTimeValueValidator.MissingDateAndTimeErrorMessage = resourceManager.GetString(ResourceIdentifier.MissingDateAndTimeErrorMessage);
                dateTimeValueValidator.MissingDateOrTimeErrorMessage  = resourceManager.GetString(ResourceIdentifier.MissingDateOrTimeErrorMessage);
                dateTimeValueValidator.MissingDateErrorMessage        = resourceManager.GetString(ResourceIdentifier.MissingDateErrorMessage);
                dateTimeValueValidator.MissingTimeErrorMessage        = resourceManager.GetString(ResourceIdentifier.MissingTimeErrorMessage);
                dateTimeValueValidator.InvalidDateAndTimeErrorMessage = resourceManager.GetString(ResourceIdentifier.InvalidDateAndTimeErrorMessage);
                dateTimeValueValidator.InvalidDateErrorMessage        = resourceManager.GetString(ResourceIdentifier.InvalidDateErrorMessage);
                dateTimeValueValidator.InvalidTimeErrorMessage        = resourceManager.GetString(ResourceIdentifier.InvalidTimeErrorMessage);
            }
            else
            {
                dateTimeValueValidator.ErrorMessage = _errorMessage;
            }
            return(dateTimeValueValidator);
        }