예제 #1
0
        /// <summary>
        /// Validate Data Type.
        /// </summary>
        private ValidationRule DataTypeValidate(IControlHabanero ctrl)
        {
            ValidationRule        returnRule = new ValidationRule();
            List <ValidationRule> vr         = this._validationRules[ctrl];

            vr.ForEach(delegate(ValidationRule obj)
            {
                if (obj != null && obj.Operator.Equals(ValidationCompareOperator.DataTypeCheck))
                {
                    if (obj.DataType.Equals(this._defaultValidationRule.DataType))
                    {
                        returnRule = obj;
                    }
                    else
                    {
                        System.Web.UI.WebControls.ValidationDataType vdt =
                            (System.Web.UI.WebControls.ValidationDataType)Enum.Parse(typeof(System.Web.UI.WebControls.
                                                                                            ValidationDataType), obj.DataType.ToString());

                        obj.IsValid = ValidationUtil.CanConvert(ctrl.Text, vdt);
                        returnRule  = obj;
                    }
                }
            });
            return(returnRule);
        }
예제 #2
0
        /// <summary>
        /// Validate Data Type.
        /// </summary>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        private ValidationRule DataTypeValidate(Control ctrl)
        {
            ValidationRule vr = this._ValidationRules[ctrl] as ValidationRule;

            if (vr != null && vr.Operator.Equals(ValidationCompareOperator.DataTypeCheck))
            {
                if (vr.DataType.Equals(this._DefaultValidationRule.DataType))
                {
                    return(vr);
                }

                System.Web.UI.WebControls.ValidationDataType vdt =
                    (System.Web.UI.WebControls.ValidationDataType)Enum.Parse(
                        typeof(System.Web.UI.WebControls.ValidationDataType),
                        vr.DataType.ToString());

                vr.IsValid = ValidationUtil.CanConvert(ctrl.Text, vdt);
            }

            return(vr);
        }