public static IFormInputControl GetInputControlByType(FormInputType type, FormInput properties) { IFormInputControl inputControl = (IFormInputControl)Activator.CreateInstance(Inputs[type]); inputControl.SetProperties(properties); return(inputControl); }
internal Input(BootstrapHelper helper, FormInputType inputType) : base(helper, "input", Css.FormControl) { OutputEndTag = false; Icon = Icon.None; MergeAttribute("type", inputType.GetDescription()); }
internal Input(BootstrapHelper helper, FormInputType inputType) : base(helper, "input", Css.FormControl) { OutputEndTag = false; Icon = Icon.None; MergeAttribute("type", inputType.GetDescription()); }
public FormData(FormInputType inputType, string Value, string Name, string DisplayText, bool IsRequired, bool?IsComparision = false, string CompareWith = default(string)) { this.inputType = inputType; this.Name = Name; this.Value = Value; this.DisplayText = DisplayText; this.IsRequired = IsRequired; this.IsComparision = IsComparision; this.CompareWith = CompareWith; }
public ActionResult List(SettingsListModel model) { if (model == null) { model = new SettingsListModel(); } if (Request.IsAjaxRequest()) { IList <SettingValue> values = _settingService.SelectSettingValues(model.Ordering, model.SettingDefId.Value). Where(value => value.IsHiddenFromUser == false).ToList(); SettingDefinition settingDef = _settingService.GetSettingDefinitionById(model.SettingDefId.Value); foreach (SettingValue settingVal in values) { for (int i = 1; i <= 15; i++) { FormInputType type = (FormInputType)typeof(SettingDefinition).GetProperty("FieldInputType" + i.ToString()).GetValue(settingDef, null); if (type == FormInputType.Password) { typeof(SettingValue).GetProperty("Field" + i.ToString()).SetValue(settingVal, "******"); } } } return(DataTableResult(values as IList)); } else { IEnumerable <SettingDefinition> settingDefList = _settingService.SelectAllSettingDefinitions(); //Some settings has their own maangement page model.SettingDefinitionSelectList = settingDefList .Where(p => p.Name != AvailableSettings.EMailSetting && p.Name != AvailableSettings.HTMLTemplate && p.Name != AvailableSettings.MembershipSetting && p.Name != AvailableSettings.AppSetting) .Select(p => new SelectListItem { Value = p.Id.ToString(), Text = p.Name + " (" + p.Description + ")" }).ToList(); model.SettingDefinitions = settingDefList; return(View(model)); } }
/// <summary> /// Encrypts password fields of the setting value to store it securely /// </summary> /// <param name="settingValue">Value</param> /// <param name="settingDefiniton">Definition</param> /// <returns>Encrypted application setting value</returns> private SettingValue Encrypt(SettingValue settingValue, SettingDefinition settingDefiniton) { if (settingValue == null || settingDefiniton == null) { return(settingValue); } for (int i = 1; i <= 15; i++) { FormInputType inputType = (FormInputType)settingDefiniton.GetType().GetProperty("FieldInputType" + i.ToString()).GetValue(settingDefiniton, null); if (inputType == FormInputType.Password) { string value = (string)settingValue.GetType().GetProperty("Field" + i.ToString()).GetValue(settingValue, null); value = _encryptionProvider.Encrypt(value, _configurationFactory().SymmetricKey); settingValue.GetType().GetProperty("Field" + i.ToString()).SetValue(settingValue, value); } } return(settingValue); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, Input> InputFor <TModel, TValue>( this ComponentWrapper <MvcBootstrapConfig <TModel>, InputGroup> wrapper, Expression <Func <TModel, TValue> > expression, FormInputType inputType = FormInputType.Text) { ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, wrapper.GetConfig().HtmlHelper.ViewData); string expressionText = ExpressionHelper.GetExpressionText(expression); string name = GetControlName(wrapper, expressionText); return(wrapper.Input(name, metadata.Model, metadata.EditFormatString, inputType)); }
public static bool validateForm(List <FormData> lsFormData, out string outputMessage) { bool boolResponse = true; outputMessage = "<ul>"; foreach (FormData formData in lsFormData) { string DisplayText = formData.DisplayText; string Name = formData.Name; string Value = formData.Value; string CompareWith = formData.CompareWith; FormInputType formInputType = formData.inputType; bool isRequired = formData.IsRequired; bool? isComparision = formData.IsComparision; if (isRequired && (string.IsNullOrEmpty(Value) || Value.Trim().Length == 0)) { outputMessage = outputMessage + "<li> " + DisplayText + " is required. </li>"; boolResponse = false; continue; } if (!isRequired && string.IsNullOrEmpty(Value)) { continue; } switch (formData.inputType) { case FormInputType.TextNotEmpty: { if (!StringHelper.IsEmpty(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } break; } case FormInputType.NumericOrZero: { if (!StringHelper.IsNumericOrZero(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } break; } case FormInputType.NameWithSpace: { if (!StringHelper.IsValidNameWithSpace(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } break; } case FormInputType.MobileNumber: { if (!StringHelper.IsNumeric(Value) || Value.Length != 10) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.PhoneNumber: { if (!StringHelper.IsNumeric(Value) || Value.Length != 10) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.Email: { if (!StringHelper.IsValidEmail(Value) && !string.IsNullOrEmpty(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.State: { if (!StringHelper.IsNumericNotZero(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.City: { if (!StringHelper.IsNumericNotZero(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.Age: { if (!StringHelper.IsNumericNotZero(Value) || !(Convert.ToInt32(Value) > 0 && Convert.ToInt32(Value) < 130)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.Date: { if (!StringHelper.IsValidDataType(DataType.DATE, Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.Height: { if (!StringHelper.IsValidDataType(DataType.DECIMAL, Value) || Convert.ToDecimal(Value) > 210) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.Weight: { if (!StringHelper.IsValidDataType(DataType.DECIMAL, Value) || Convert.ToDecimal(Value) > 300) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; case FormInputType.DropDownListValue: { if (!StringHelper.IsNumericNotZero(Value)) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } break; default: break; } if ((isComparision ?? false) && Value != CompareWith) { outputMessage = outputMessage + FormValidator.getErrorMessage(DisplayText); boolResponse = false; } } outputMessage = outputMessage + "</ul>"; return(boolResponse); }
// Use special creator extensions to create input group addons so we can control the output more closely (I.e., no labels, form groups, etc.) public static ComponentBuilder <TConfig, Input> Input <TConfig>(this ComponentWrapper <TConfig, InputGroup> wrapper, string name = null, object value = null, string valueFormat = null, FormInputType inputType = FormInputType.Text) where TConfig : BootstrapConfig { return(new ComponentBuilder <TConfig, Input>(wrapper.Config, new Input(wrapper, inputType)) .SetName(name) //.SetControlLabel(label) .SetValue(value, valueFormat) .EnsureFormGroup(false)); }
//Input Date /// <summary> /// Add By Jubpas /// </summary> /// <typeparam name="TConfig"></typeparam> /// <typeparam name="TComponent"></typeparam> /// <param name="helper"></param> /// <param name="name"></param> /// <param name="label"></param> /// <param name="value"></param> /// <param name="valueFormat"></param> /// <param name="inputType"></param> /// <returns></returns> public static ComponentBuilder <TConfig, Input> Datepicker <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, FormInputType inputType = FormInputType.Text, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false, bool isCuttom = false) where TConfig : BootstrapConfig where TComponent : Component, ICanCreate <Input> { ComponentBuilder <TConfig, Input> nhelper = new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, inputType)) .SetName(name) .SetControlLabel(label) .SetValue(value, valueFormat) .SetValidateMassage(addValidateMessage, validateMassegeTag) .SetRequired(isRequired) .SetSize(InputSize.Sm); if (!string.IsNullOrEmpty(valueFormat)) { Regex regex = new Regex(@"\{\d:([^)]+)\}$"); var match = regex.Match(valueFormat); if (match.Success) { nhelper.AddAttribute("data-date-format", match.Groups[1].Value); } } if (!isCuttom) { nhelper.AddCss("datepicker") .AddCss("datepicker-input"); } else { nhelper.AddCss("datepicker-input"); } if (isRequired) { nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired); } return(nhelper); }
// Spinner By jubpas public static ComponentBuilder <TConfig, Input> InputSpinner <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, FormInputType inputType = FormInputType.Text) where TConfig : BootstrapConfig where TComponent : Component, ICanCreate <Input> { return(new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, inputType)) .SetName(name) .AddAttribute("data-min", 0) .AddAttribute("data-max", 100) .AddAttribute("data-step", 10) .AddCss("spinner-input") .SetControlLabel(label) .SetValue(value, valueFormat)); }
internal Input(IComponentCreator <THelper> creator, FormInputType inputType) : base(creator, "input", Css.FormControl) { MergeAttribute("type", inputType.GetDescription()); }
// Use special creator extensions to create input group addons so we can control the output more closely (I.e., no labels, form groups, etc.) public static Input <THelper> Input <THelper>(this InputGroupWrapper <THelper> inputGroup, string name = null, object value = null, string format = null, FormInputType inputType = FormInputType.Text) where THelper : BootstrapHelper <THelper> { return(new Input <THelper>(inputGroup, inputType).SetName(name).SetValue(value, format).EnsureFormGroup(false)); }
// Input public static Input <THelper> Input <THelper>(this IFormControlCreator <THelper> creator, string name = null, string label = null, object value = null, string format = null, FormInputType inputType = FormInputType.Text) where THelper : BootstrapHelper <THelper> { return(new Input <THelper>(creator, inputType).SetName(name).SetControlLabel(label).SetValue(value, format)); }
// Input public static ComponentBuilder <TConfig, Input> Input <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, FormInputType inputType = FormInputType.Text) where TConfig : BootstrapConfig where TComponent : Component, ICanCreate <Input> { return(new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, inputType)) .SetName(name) .SetControlLabel(label) .SetValue(value, valueFormat)); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, Input> InputFor <TComponent, TModel, TValue>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > expression, FormInputType inputType = FormInputType.Text) where TComponent : Component, ICanCreate <Input> { ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, helper.GetConfig().HtmlHelper.ViewData); string expressionText = ExpressionHelper.GetExpressionText(expression); string name = GetControlName(helper, expressionText); string label = GetControlLabel(metadata, expressionText); return(helper.Input(name, label, metadata.Model, null, inputType)); }
public FormAttribute(FormInputType type) { Type = type; }