private FWInputElement CreateDatepickerInput(FWDivElement element)
        {
            FWInputElement input = CreateInput(element);

            input.AddCssClass("form-control datetimepicker-input");

            if (!string.IsNullOrWhiteSpace(_placeholder))
            {
                input.Attributes.Add("placeholder", _placeholder);
            }

            input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.DATEPICKER);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = (!_hasTimePicker) ?
                              ((DateTime)Model).ToString("yyyy-MM-dd") :
                              ((DateTime)Model).ToString("yyyy-MM-ddTHH:mm:ss");
            }

            if (IsReadOnly)
            {
                input.Attributes.Add("readonly", "readonly");
            }

            return(input);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the control main element.
        /// </summary>
        /// <returns>The control IFWHtmlElement interface.</returns>
        protected override IFWHtmlElement CreateControl()
        {
            var input = new FWInputElement(Name, FWInputType.Hidden);

            input.MergeAttributes(Attributes);
            if (!string.IsNullOrWhiteSpace(CustomCss))
            {
                input.AddCssClass(CustomCss);
            }

            input.Id       = Id;
            input.DataType = "fw-hidden";

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.VALUE);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = Model.ToString();
            }
            else if (FWReflectionHelper.IsNumeric(ModelType))
            {
                // If the property is a number, but the model is null, the value defaults to 0.
                input.Value = "0";
            }

            return(input);
        }
Ejemplo n.º 3
0
        private FWInputElement CreateInput()
        {
            var input = new FWInputElement(Name, FWInputType.Textbox);

            input.AddCssClass("form-control");

            input.Attributes.Add("data-thousands", CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator);
            input.Attributes.Add("data-decimal", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            input.Attributes.Add("data-allownegative", _allowNegative ? "true" : "false");

            input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));

            if (IsReadOnly)
            {
                input.Attributes.Add("readonly", "readonly");
            }

            if (_displayCurrency)
            {
                input.Attributes.Add("data-prefix", CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol);
            }

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.CURRENCY);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = Model.ToString();
            }

            return(input);
        }
Ejemplo n.º 4
0
        private FWInputElement CreateInput()
        {
            var input = new FWInputElement(Name, (!_isPassword) ? FWInputType.Textbox : FWInputType.Password);

            input.AddCssClass("form-control");

            if (!string.IsNullOrWhiteSpace(_placeholder))
            {
                input.Attributes.Add("placeholder", _placeholder);
            }

            input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));

            if (IsReadOnly)
            {
                input.Attributes.Add("readonly", "readonly");
            }

            if (IsDisabled)
            {
                input.Attributes.Add("disabled", "disabled");
            }

            if (_maxLength > 0)
            {
                input.Attributes.Add("maxlength", _maxLength.ToString());
            }

            if (_minLength > 0)
            {
                input.Attributes.Add("data-rule-minlength", _minLength.ToString());
                input.Attributes.Add("data-msg-minlength", string.Format(ViewResources.Validation_MinLength, DisplayName, _minLength));
            }

            if (_regexPattern != null)
            {
                input.Attributes.Add("data-rule-pattern", _regexPattern);
                input.Attributes.Add("data-msg-pattern", string.Format(ViewResources.Validation_Regex, DisplayName));
            }

            if (_targetValidationField != null)
            {
                input.Attributes.Add("data-rule-passwordmatch", _targetValidationField);
                input.Attributes.Add("data-msg-passwordmatch", ViewResources.Validation_PasswordMismatch);
            }

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.VALUE);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = Model.ToString();
            }

            return(input);
        }