Esempio n. 1
0
 public static void DoPreRenderRegistration(WhidbeyBaseValidator validator, IBaseValidatorAccessor validatorAccessor)
 {
     if (validatorAccessor.RenderUpLevel)
     {
         ScriptManager.RegisterClientScriptResource(validator, typeof(WhidbeyBaseValidator), ValidatorFileName);
         ScriptManager.RegisterStartupScript(validator, typeof(WhidbeyBaseValidator), ValidatorIncludeScriptKey, ValidatorStartupScript, true);
         ScriptManager.RegisterOnSubmitStatement(validator,
                                                 typeof(WhidbeyBaseValidator),
                                                 "ValidatorOnSubmit",
                                                 "if (typeof(ValidatorOnSubmit) == \"function\" && ValidatorOnSubmit() == false) return false;");
     }
 }
Esempio n. 2
0
        //public static void DoBaseCompareValidatorAddAttributes(WhidbeyBaseCompareValidator validator, IBaseCompareValidatorAccessor validatorAccessor) {
        //    if (validatorAccessor.RenderUpLevel) {
        //        ValidationDataType type = validator.Type;
        //        if (type != ValidationDataType.String) {
        //            string id = validator.ClientID;

        //            ValidatorHelper.AddExpandoAttribute(validator, id, "type", PropertyConverter.EnumToString(typeof(ValidationDataType), type), false);

        //            NumberFormatInfo info = NumberFormatInfo.CurrentInfo;
        //            if (type == ValidationDataType.Double) {
        //                string decimalChar = info.NumberDecimalSeparator;
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "decimalchar", decimalChar);
        //            }
        //            else if (type == ValidationDataType.Currency) {
        //                string decimalChar = info.CurrencyDecimalSeparator;
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "decimalchar", decimalChar);

        //                string groupChar = info.CurrencyGroupSeparator;
        //                if (groupChar[0] == 160)
        //                    groupChar = " ";
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "groupchar", groupChar);

        //                int digits = info.CurrencyDecimalDigits;
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "digits", digits.ToString(NumberFormatInfo.InvariantInfo), false);

        //                int groupSize = GetCurrencyGroupSize(info);
        //                if (groupSize > 0) {
        //                    ValidatorHelper.AddExpandoAttribute(validator, id, "groupsize", groupSize.ToString(NumberFormatInfo.InvariantInfo), false);
        //                }
        //            }
        //            else if (type == ValidationDataType.Date) {
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "dateorder", validatorAccessor.GetDateElementOrder(), false);
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "cutoffyear", validatorAccessor.CutoffYear.ToString(NumberFormatInfo.InvariantInfo), false);

        //                int currentYear = DateTime.Today.Year;
        //                int century = currentYear - (currentYear % 100);
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "century", century.ToString(NumberFormatInfo.InvariantInfo), false);
        //            }
        //        }
        //    }
        //}

        public static void DoBaseValidatorAddAttributes(WhidbeyBaseValidator validator, IBaseValidatorAccessor validatorAccessor, HtmlTextWriter writer) {
            bool disabled = !validator.Enabled;
            if (disabled) {
                validator.Enabled = true;
            }

            try {
                if (validatorAccessor.RenderUpLevel) {
                    validatorAccessor.EnsureID();
                    string id = validator.ClientID;

                    if (validator.ControlToValidate.Length > 0) {
                        AddExpandoAttribute(validator, id, "controltovalidate", validatorAccessor.GetControlRenderID(validator.ControlToValidate));
                    }
                    if (validator.SetFocusOnError) {
                        AddExpandoAttribute(validator, id, "focusOnError", "t", false);
                    }
                    if (validator.ErrorMessage.Length > 0) {
                        AddExpandoAttribute(validator, id, "errormessage", validator.ErrorMessage);
                    }
                    ValidatorDisplay display = validator.Display;
                    if (display != ValidatorDisplay.Static) {
                        AddExpandoAttribute(validator, id, "display", PropertyConverter.EnumToString(typeof(ValidatorDisplay), display), false);
                    }
                    if (!validator.IsValid) {
                        AddExpandoAttribute(validator, id, "isvalid", "False", false);
                    }
                    if (disabled) {
                        AddExpandoAttribute(validator, id, "enabled", "False", false);
                    }
                    if (validator.ValidationGroup.Length > 0) {
                        AddExpandoAttribute(validator, id, "validationGroup", validator.ValidationGroup);
                    }
                }

                DoWebControlAddAttributes(validator, validatorAccessor, writer);
            }
            finally {
                if (disabled) {
                    validator.Enabled = false;
                }
            }

        }
 public static void DoPreRenderRegistration(WhidbeyBaseValidator validator, IBaseValidatorAccessor validatorAccessor)
 {
     if(validatorAccessor.RenderUpLevel) {
         ScriptManager.RegisterClientScriptResource(validator, typeof(WhidbeyBaseValidator), ValidatorFileName);
         ScriptManager.RegisterStartupScript(validator, typeof(WhidbeyBaseValidator), ValidatorIncludeScriptKey, ValidatorStartupScript, true);
         ScriptManager.RegisterOnSubmitStatement(validator,
             typeof(WhidbeyBaseValidator),
             "ValidatorOnSubmit",
             "if (typeof(ValidatorOnSubmit) == \"function\" && ValidatorOnSubmit() == false) return false;");
     }
 }
Esempio n. 4
0
        //public static void DoBaseCompareValidatorAddAttributes(WhidbeyBaseCompareValidator validator, IBaseCompareValidatorAccessor validatorAccessor) {
        //    if (validatorAccessor.RenderUpLevel) {
        //        ValidationDataType type = validator.Type;
        //        if (type != ValidationDataType.String) {
        //            string id = validator.ClientID;

        //            ValidatorHelper.AddExpandoAttribute(validator, id, "type", PropertyConverter.EnumToString(typeof(ValidationDataType), type), false);

        //            NumberFormatInfo info = NumberFormatInfo.CurrentInfo;
        //            if (type == ValidationDataType.Double) {
        //                string decimalChar = info.NumberDecimalSeparator;
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "decimalchar", decimalChar);
        //            }
        //            else if (type == ValidationDataType.Currency) {
        //                string decimalChar = info.CurrencyDecimalSeparator;
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "decimalchar", decimalChar);

        //                string groupChar = info.CurrencyGroupSeparator;
        //                if (groupChar[0] == 160)
        //                    groupChar = " ";
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "groupchar", groupChar);

        //                int digits = info.CurrencyDecimalDigits;
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "digits", digits.ToString(NumberFormatInfo.InvariantInfo), false);

        //                int groupSize = GetCurrencyGroupSize(info);
        //                if (groupSize > 0) {
        //                    ValidatorHelper.AddExpandoAttribute(validator, id, "groupsize", groupSize.ToString(NumberFormatInfo.InvariantInfo), false);
        //                }
        //            }
        //            else if (type == ValidationDataType.Date) {
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "dateorder", validatorAccessor.GetDateElementOrder(), false);
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "cutoffyear", validatorAccessor.CutoffYear.ToString(NumberFormatInfo.InvariantInfo), false);

        //                int currentYear = DateTime.Today.Year;
        //                int century = currentYear - (currentYear % 100);
        //                ValidatorHelper.AddExpandoAttribute(validator, id, "century", century.ToString(NumberFormatInfo.InvariantInfo), false);
        //            }
        //        }
        //    }
        //}

        public static void DoBaseValidatorAddAttributes(WhidbeyBaseValidator validator, IBaseValidatorAccessor validatorAccessor, HtmlTextWriter writer)
        {
            bool disabled = !validator.Enabled;

            if (disabled)
            {
                validator.Enabled = true;
            }

            try {
                if (validatorAccessor.RenderUpLevel)
                {
                    validatorAccessor.EnsureID();
                    string id = validator.ClientID;

                    if (validator.ControlToValidate.Length > 0)
                    {
                        AddExpandoAttribute(validator, id, "controltovalidate", validatorAccessor.GetControlRenderID(validator.ControlToValidate));
                    }
                    if (validator.SetFocusOnError)
                    {
                        AddExpandoAttribute(validator, id, "focusOnError", "t", false);
                    }
                    if (validator.ErrorMessage.Length > 0)
                    {
                        AddExpandoAttribute(validator, id, "errormessage", validator.ErrorMessage);
                    }
                    ValidatorDisplay display = validator.Display;
                    if (display != ValidatorDisplay.Static)
                    {
                        AddExpandoAttribute(validator, id, "display", PropertyConverter.EnumToString(typeof(ValidatorDisplay), display), false);
                    }
                    if (!validator.IsValid)
                    {
                        AddExpandoAttribute(validator, id, "isvalid", "False", false);
                    }
                    if (disabled)
                    {
                        AddExpandoAttribute(validator, id, "enabled", "False", false);
                    }
                    if (validator.ValidationGroup.Length > 0)
                    {
                        AddExpandoAttribute(validator, id, "validationGroup", validator.ValidationGroup);
                    }
                }

                DoWebControlAddAttributes(validator, validatorAccessor, writer);
            }
            finally {
                if (disabled)
                {
                    validator.Enabled = false;
                }
            }
        }