public string ToHtml() { TagAttributeList attributes = new TagAttributeList() { new TagAttribute(Attr.Type, "checkbox"), new TagAttribute(Attr.Name, "optionsCheckboxes"), }; if (this.isChecked) { attributes.Add(new TagAttribute(Attr.Checked)); } if (this.isDisabled) { attributes.Add(new TagAttribute(Attr.Disabled)); } var input = TagHelper.SelfClosingTag(Tag.input, attributes); input.PostElement.SetContent(this.text); var label = TagHelper.Create(Tag.label, input); var div = TagHelper.Div("checkbox", label); return(TagHelper.ToHtml(div)); }
public IHtmlContent Render(TModel entity) { string id = new Identifier().Value; DateTime?value = default; string name = this.expression.GetPropertyName(); var attributes = new TagAttributeList { { Attr.Type, "text" }, { Attr.Class, $"form-control {this.Type.ToString().ToLower()}picker" }, { Attr.Name, name }, { Attr.Id, id }, { Attr.AutoComplete, "off" }, }; if (entity != null) { value = this.modelExpression.Compile()(entity); if (value.HasValue && value != null) { attributes.Add(Attr.Value, value); } } var label = TagHelper.Create(Tag.label, new TagAttribute(Attr.Class, "control-label"), this.lable); var input = TagHelper.Create(Tag.input, attributes); var span = TagHelper.Create(Tag.span, new TagAttribute(Attr.Class, "form-control-feedback"), new MaterialIcon("done").Html); // clear return(TagHelper.Div("form-group label-floating has-success", label, input, span)); // has-error }
public IHtmlContent Render(TModel entity) { string id = new Identifier().Value; bool? value = default; string name = this.expression.GetPropertyName(); if (entity != null) { value = this.modelExpression.Compile()(entity); } TagAttributeList attributes = new TagAttributeList { { Attr.Type, "checkbox" }, { Attr.Name, name }, }; if (value.HasValue && value.Value) { attributes.Add(new TagAttribute(Attr.Checked)); } var input = TagHelper.Create(Tag.input, attributes); var label = TagHelper.Create(Tag.label, input); label.PostElement.AppendHtml(this.text); return(TagHelper.Div("checkbox", label)); }