public TagBuilder_TextArea(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("textarea", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeIsNotNull("type", CustomAttributesHelpers.ConvertDataTypeToHtmlType((DataType)this.ComponentBase.MetadataAttributes.GetValue <DataType>("DataType", "DataType"), this.ComponentBase.FieldType));
            int?minimumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Minimum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MinimumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("minlength", minimumLength, minimumLength.HasValue && minimumLength.Value > 0);
            int?maximumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Maximum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MaximumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("maxlength", maximumLength, maximumLength.HasValue && maximumLength.Value > 0);
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("OnlyNumber", "ClassDecorator"));
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("NoEspecialChars", "ClassDecorator"));
            TagElement.AddInputAttributeIsNotNull("cols", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "Cols"));
            TagElement.AddInputAttributeIsNotNull("rows", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "Rows"));
            TagElement.AddInputAttributeIsNotNull("wrap", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "Wrap"));
            TagElement.AddInputAttributeIsNotNull("minlength", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "MinLength"));
            TagElement.AddInputAttributeIsNotNull("maxlength", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "MaxLength"));

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("type", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("minlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("maxlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("cols", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("rows", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("wrap", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
            TagElement.InnerHtml = this.Value?.ToString();
        }
Esempio n. 2
0
        public TagBuilder_Progress(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("progress", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            int?minimumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Minimum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MinimumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("minlength", minimumLength, minimumLength.HasValue && minimumLength.Value > 0);
            int?maximumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Maximum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MaximumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("maxlength", maximumLength, maximumLength.HasValue && maximumLength.Value > 0);

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            //TagElement.DeleteValueInAttribute("class", "form-control");
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("minlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("maxlength", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            double?maxValue = this.ComponentBase.MetadataAttributes.GetValue <double>("ProgressAttribute", "MaxValue");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("max", maxValue, maxValue != null);
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("value", this.Value, this.Value != null);
        }
Esempio n. 3
0
        public TagBuilder_Password(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("input", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeStaticValue("type", "password");
            int?minimumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Minimum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MinimumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("minlength", minimumLength, minimumLength.HasValue && minimumLength.Value > 0);
            int?maximumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Maximum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MaximumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("maxlength", maximumLength, maximumLength.HasValue && maximumLength.Value > 0);
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("OnlyNumber", "ClassDecorator"));
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("Currency", "ClassDecorator"));
            TagElement.MergeInputAttributeIsNotNull("pattern", this.ComponentBase.MetadataAttributes.GetValue <object>("Currency", "Pattern"));
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("NoEspecialChars", "ClassDecorator"));

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("minlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("maxlength", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
        }
        private void InicializeTagElement()
        {
            this.TagElement = new TagBuilder(TagElementType);
            //TagElement.GenerateId(fieldFullName);
            TagElement.AddInputAttributeIsNotNull("id", this.ComponentBase.SanitizedId);
            TagElement.AddInputAttributeIsNotNull("name", this.ComponentBase.FieldFullName);

            //...............................................................................................................................................................\\
            bool _IsRequired = !this.ComponentBase.FieldIsNullable || this.ComponentBase.MetadataAttributes.GetValue <bool>("Common", "IsRequired");

            if (_IsRequired)
            {
                TagElement.AddInputAttributeStaticValue("required", null);
            }
            bool _IsNullable = this.ComponentBase.FieldIsNullable || this.ComponentBase.MetadataAttributes.GetValue <bool>("Common", "IsNullable") || this.ComponentBase.MetadataAttributes.GetValue <bool>("Common", "IsNullableValueType");

            //...............................................................................................................................................................\\


            /* Adicionar os atributos de acordo com o que for obtido no MetaData... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeStaticValue("class", "form-control");
            TagElement.AddInputAttributeIsNotNull("autofocus", this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "Autofocus"));
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("required", null, (bool)this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "IsRequired"));
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("readonly", null, this.ComponentBase.FieldIsReadOnly || (bool)this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "IsReadOnly"));
            TagElement.AddInputAttributeIsNotNull("title", this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "Description"));
            TagElement.AddInputAttributeIsNotNull("placeholder", this.ComponentBase.MetadataAttributes.GetValue <object>("PlaceHolder", "Text") ?? this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "Watermark"));

            //...............................................................................................................................................................\\

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("required", null, !this.ComponentBase.FieldIsNullable);
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("readonly", null, this.ComponentBase.FieldIsReadOnly);
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("disabled", null, this.ComponentBase.FieldIsDisabled);

            //...............................................................................................................................................................\\

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.AddInputAttributeHtmlAttributes("autofocus", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("required", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("readonly", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("disabled", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("title", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("placeholder", this.ComponentBase.HtmlAttributes);

            //...............................................................................................................................................................\\

            /* Adicionar os atributos de acordo com o que for obtido no Data-Val... */
            //TagElement.AddInputAttributeStaticValue("data-val", "true");
            TagElement.AddInputAttributeIsNotNull("data-val-required", this.ComponentBase.MetadataAttributes.GetValue <object>("Required", "ErrorMessage"));
            //TagElement.AddInputAttributeStaticValue("data-val-regex-pattern", "");
            //TagElement.AddInputAttributeStaticValue("data-val-regex", "");

            this.Value = this.ComponentBase.FieldValue;
        }
        public TagBuilder_Label(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase, string id, string caption, string forInput, string tooltip = null)
            : base("label", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com os parâmetros informados... */
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("id", id ?? $"label.{forInput}", (id ?? $"label.{forInput}") != null);
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("for", forInput, forInput != null);
            if (tooltip != null && !string.IsNullOrEmpty(tooltip))
            {
                TagElement.AddInputAttributeStaticValue("data-toggle", "tooltip");
                TagElement.AddInputAttributeStaticValue("data-placement", "top");
                TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("data-original-title", tooltip, tooltip != null);
            }

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.AddInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            TagElement.InnerHtml = caption;
        }