protected override bool ControlPropertiesValid() { if (this.ControlToCompare.Length > 0) { base.CheckControlValidationProperty(this.ControlToCompare, "ControlToCompare"); if (StringUtil.EqualsIgnoreCase(base.ControlToValidate, this.ControlToCompare)) { throw new HttpException(System.Web.SR.GetString("Validator_bad_compare_control", new object[] { this.ID, this.ControlToCompare })); } } else if ((this.Operator != ValidationCompareOperator.DataTypeCheck) && !BaseCompareValidator.CanConvert(this.ValueToCompare, base.Type, base.CultureInvariantValues)) { throw new HttpException(System.Web.SR.GetString("Validator_value_bad_type", new string[] { this.ValueToCompare, "ValueToCompare", this.ID, PropertyConverter.EnumToString(typeof(ValidationDataType), base.Type) })); } return(base.ControlPropertiesValid()); }
private void ValidateValues() { string maximumValue = this.MaximumValue; if (!BaseCompareValidator.CanConvert(maximumValue, base.Type, base.CultureInvariantValues)) { throw new HttpException(System.Web.SR.GetString("Validator_value_bad_type", new string[] { maximumValue, "MaximumValue", this.ID, PropertyConverter.EnumToString(typeof(ValidationDataType), base.Type) })); } string minimumValue = this.MinimumValue; if (!BaseCompareValidator.CanConvert(minimumValue, base.Type, base.CultureInvariantValues)) { throw new HttpException(System.Web.SR.GetString("Validator_value_bad_type", new string[] { minimumValue, "MinimumValue", this.ID, PropertyConverter.EnumToString(typeof(ValidationDataType), base.Type) })); } if (BaseCompareValidator.Compare(minimumValue, base.CultureInvariantValues, maximumValue, base.CultureInvariantValues, ValidationCompareOperator.GreaterThan, base.Type)) { throw new HttpException(System.Web.SR.GetString("Validator_range_overalap", new string[] { maximumValue, minimumValue, this.ID })); } }
protected override bool ControlPropertiesValid() { if ((this.Operator != ValidationCompareOperator.DataTypeCheck) && ControlToCompare.Length == 0 && !BaseCompareValidator.CanConvert(this.ValueToCompare, this.Type, this.CultureInvariantValues)) { throw new HttpException( String.Format("Unable to convert the value: {0} as a {1}", ValueToCompare, Enum.GetName(typeof(ValidationDataType), this.Type))); } if (ControlToCompare.Length > 0) { if (string.CompareOrdinal(ControlToCompare, ControlToValidate) == 0) { throw new HttpException(String.Format("Control '{0}' cannot have the same value '{1}' for both ControlToValidate and ControlToCompare.", ID, ControlToCompare)); } CheckControlValidationProperty(ControlToCompare, ""); } return(base.ControlPropertiesValid()); }