/// <summary>
        /// Erzeugt einen Validator vom entsprechenden Typ.
        /// </summary>
        /// <param name="validatorType"></param>
        /// <returns></returns>
        public static IValidator CreateValidator(ModuleConfig.ValidationData validator)
        {
            switch (validator.FieldType)
            {
            case ModuleConfig.ValidationData.ValidationType.Text:
                return(new ValidatorText(validator));

                break;

            case ModuleConfig.ValidationData.ValidationType.Email:
                return(new ValidatorEmail(validator));

                break;

            case ModuleConfig.ValidationData.ValidationType.Number:
                return(new ValidatorNumber(validator));

                break;

            case ModuleConfig.ValidationData.ValidationType.RegularExpression:
                return(new ValidatorRegex(validator));

                break;

            default:
                return(null);

                break;
            }
        }
        protected void OnDetailsViewDataBind(object sender, EventArgs e)
        {
            ModuleConfig.ValidationData validationData = (ModuleConfig.ValidationData)((GridViewRow)((Control)sender).BindingContainer).DataItem;
            IValidator validatorObj = ValidatorFactory.CreateValidator(validationData);

            if (validatorObj != null)
            {
                validatorObj.AddValidatorSettingsView((Control)sender);
            }
        }
 protected void OnAddNewValidator(object sender, EventArgs e)
 {
   int pos = _validators.Count;
   ModuleConfig.ValidationData validData = new ModuleConfig.ValidationData();
   validData.ErrorMessage = Portal.API.Language.GetText(this, "DefaultErrorMessage");
   _validators.Insert(pos, validData);
   _fieldValidators.EditIndex = pos;
   _fieldValidators.DataSource = _validators;
   _fieldValidators.DataBind();
 }
        protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = _fieldValidators.Rows[e.RowIndex];

            ModuleConfig.ValidationData data = _validators[e.RowIndex];
            ApplyData(row, data);

            _fieldValidators.EditIndex  = -1;
            _fieldValidators.DataSource = _validators;
            _fieldValidators.DataBind();
        }
        protected void OnAddNewValidator(object sender, EventArgs e)
        {
            int pos = _validators.Count;

            ModuleConfig.ValidationData validData = new ModuleConfig.ValidationData();
            validData.ErrorMessage = Portal.API.Language.GetText(this, "DefaultErrorMessage");
            _validators.Insert(pos, validData);
            _fieldValidators.EditIndex  = pos;
            _fieldValidators.DataSource = _validators;
            _fieldValidators.DataBind();
        }
        private static void ApplyData(GridViewRow row, ModuleConfig.ValidationData data)
        {
            data.FieldName    = ((DropDownList)row.FindControl("_fieldName")).Text;
            data.FieldType    = (ModuleConfig.ValidationData.ValidationType)Enum.Parse(typeof(ModuleConfig.ValidationData.ValidationType), ((DropDownList)row.FindControl("_fieldType")).SelectedValue);
            data.ErrorMessage = ((TextBox)row.FindControl("_errorMessage")).Text;
            data.IsMandatory  = ((CheckBox)row.FindControl("_mandatoryCheck")).Checked;

            IValidator validatorObj = ValidatorFactory.CreateValidator(data);

            if (validatorObj != null)
            {
                validatorObj.SaveValidatorSettings(row.FindControl("_detailsEdit"));
            }
        }
        protected void OnTypeChanged(Object sender, EventArgs e)
        {
            DropDownList dropDown  = (DropDownList)sender;
            string       typeValue = dropDown.SelectedValue;
            GridViewRow  gridRow   = (GridViewRow)dropDown.BindingContainer;

            ModuleConfig.ValidationData data = _validators[gridRow.DataItemIndex];

            // Zuerst die gemachten Änderungen übernehmen.
            ApplyData(gridRow, data);

            data.FieldType = (ModuleConfig.ValidationData.ValidationType)Enum.Parse(typeof(ModuleConfig.ValidationData.ValidationType), typeValue);
            _fieldValidators.DataSource = _validators;
            _fieldValidators.DataBind();
        }
        protected void OnNameComboDataBind(object sender, EventArgs e)
        {
            DropDownList ddList = ((DropDownList)sender);

            // Verfügbare Felder laden.
            ModuleConfig config = (ModuleConfig)ReadConfig(typeof(ModuleConfig));

            if (config == null)
            {
                config = new ModuleConfig();
            }

            string[] fields = Portal.API.HtmlAnalyzer.GetInputNames(config.FormContent);

            // Falls der gewählte Eintrag nicht mehr existiert, wird der erste Wert ausgewählt.
            ModuleConfig.ValidationData validationData = (ModuleConfig.ValidationData)((GridViewRow)((Control)sender).BindingContainer).DataItem;
            if (null == Array.Find <string>(fields, delegate(string test) { return(test == validationData.FieldName); }))
            {
                ddList.SelectedValue = fields[0];
            }

            ddList.DataSource = fields;
        }
Exemple #9
0
 public ValidatorText(ModuleConfig.ValidationData data)
     : base(data)
 {
 }
Exemple #10
0
 public ValidatorRegex(ModuleConfig.ValidationData data)
     : base(data)
 {
 }
Exemple #11
0
 public Validator(ModuleConfig.ValidationData data)
 {
     _data = data;
 }
Exemple #12
0
 public ValidatorNumber(ModuleConfig.ValidationData data)
     : base(data)
 {
 }
Exemple #13
0
 public ValidatorEmail(ModuleConfig.ValidationData data)
     : base(data)
 {
 }