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(); }
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_Select(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase) : base("select", dynamicComponentBase) { /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */ TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes); TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes); /* Injetando o Valor no Input... */ this.Value = this.ComponentBase.FieldValue; TagElement.AddInputAttributeIsNotNull("value", this.Value); }
public TagBuilder_Checkbox(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase) : base(CustomAttributesHelpers.GetInputElementTypeByDataType((DataType)dynamicComponentBase.MetadataAttributes.GetValue <DataType>("DataType", "DataType")), dynamicComponentBase) { /* Adicionar os atributos de acordo com o que for obtido no Metadata... */ TagElement.AddInputAttributeStaticValue("type", "checkbox"); /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */ TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes); TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes); /* Injetando o Valor no Input... */ this.Value = this.ComponentBase.FieldValue; TagElement.AddInputAttributeIsNotNull("value", this.Value); }
public TagBuilder_Range(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase) : base("input", dynamicComponentBase) { /* Adicionar os atributos de acordo com o que for obtido no Metadata... */ //TagElement.AddInputTypeAttribute(fieldType); TagElement.AddInputAttributeIsNotNull("type", "range"); TagElement.AddInputAttributeIsNotNull("min", this.ComponentBase.MetadataAttributes.GetValue <double>("Progress", "MinValue")); TagElement.AddInputAttributeIsNotNull("max", this.ComponentBase.MetadataAttributes.GetValue <double>("Progress", "MaxValue")); TagElement.AddInputAttributeIsNotNull("step", this.ComponentBase.MetadataAttributes.GetValue <double>("Progress", "Step")); /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */ TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes); TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes); /* Injetando o Valor no Input... */ this.Value = this.ComponentBase.FieldValue; TagElement.AddInputAttributeIsNotNull("value", this.Value); }