private void RenderInput(TextWriter writer) { var tagName = "input"; var tagBuilder = new TagBuilder(tagName) { TagRenderMode = TagRenderMode.SelfClosing }; tagBuilder.Attributes.Add("name", Name); tagBuilder.Attributes.Add("type", "checkbox"); if (AutoPostBack) { tagBuilder.Attributes.Add("onclick", "this.form.submit()"); } if (Checked) { tagBuilder.Attributes.Add("checked", "checked"); } if (!Enabled) { tagBuilder.Attributes.Add("disabled", "disabled"); } if (!Visible) { tagBuilder.AddStyle(new Style { Attribute = "display", Value = "none" }); } tagBuilder.WriteTo(writer, HtmlEncoder.Default); }
public override string Get() { StringBuilder grid = new StringBuilder(); using (DataTable table = this.GetTable()) { if (table.Rows.Count.Equals(0)) { return("<div class='ui message'>No record found</div>"); } TagBuilder.Begin(grid, "table"); TagBuilder.AddId(grid, "FormGridView"); TagBuilder.AddClass(grid, ConfigBuilder.GetGridViewCssClass(this.Config)); TagBuilder.AddStyle(grid, ConfigBuilder.GetGridViewWidth(this.Config) + ";white-space: nowrap;"); TagBuilder.Close(grid); List <Column> columns = GetColumns(table).ToList(); HeaderRow header = new HeaderRow(this.Config, columns); grid.Append(header.Get()); using (Body body = new Body(this.Config, table, columns)) { grid.Append(body.Get()); } TagBuilder.EndTag(grid, "table"); } return(grid.ToString()); }
public override string Get() { StringBuilder table = new StringBuilder(); TagBuilder.Begin(table, "table"); TagBuilder.AddAttribute(table, "role", "item-selector-table"); TagBuilder.AddStyle(table, "border-collapse:collapse;width:100%;"); TagBuilder.Close(table); TagBuilder.Begin(table, "tr", true); //Select Begin TagBuilder.Begin(table, "td", true); table.Append(GetSelect()); TagBuilder.EndTag(table, "td"); //Select End //Item Selector Begin TagBuilder.Begin(table, "td"); TagBuilder.AddStyle(table, "width:24px;"); TagBuilder.Close(table); ItemSelector selector = new ItemSelector(this.Config, this.FieldConfig); table.Append(selector.Get()); TagBuilder.EndTag(table, "td"); //Item Selector End TagBuilder.EndTag(table, "tr"); TagBuilder.EndTag(table, "table"); return(table.ToString()); }
public void AddMultipleStylesShouldConcatenatedByComma() { // Arrange var builder = new TagBuilder("p"); var writer = new StringWriter(new StringBuilder()); // Act builder.InnerHtml.Append("This is paragraph"); builder.AddStyle(new Style { Attribute = "color", Value = "#f00" }); builder.AddStyle(new Style { Attribute = "font-size", Value = "14px" }); builder.WriteTo(writer, HtmlEncoder.Default); // Assert Assert.Equal("<p style=\"color:#f00;font-size:14px\">This is paragraph</p>", writer.GetStringBuilder().ToString()); }
public async override Task RenderAsync(TextWriter writer) { var tagName = "select"; var tagBuilder = new TagBuilder(tagName) { TagRenderMode = TagRenderMode.StartTag }; tagBuilder.Attributes.Add("name", Name); if (AutoPostBack) { tagBuilder.Attributes.Add("onchange", "this.form.submit()"); } if (!Enabled) { tagBuilder.Attributes.Add("disabled", "disabled"); } if (!Visible) { tagBuilder.AddStyle(new Style { Attribute = "display", Value = "none" }); } tagBuilder.WriteTo(writer, HtmlEncoder.Default); foreach (var item in Items) { item.Name = Name; if (SelectedValue != null) { item.Selected = (item.Text == SelectedValue); } await item.RenderAsync(writer); } tagBuilder = new TagBuilder(tagName) { TagRenderMode = TagRenderMode.EndTag }; tagBuilder.WriteTo(writer, HtmlEncoder.Default); await Task.CompletedTask; }
public override string Get() { StringBuilder form = new StringBuilder(); TagBuilder.Begin(form, "form"); TagBuilder.AddId(form, "FormPanel"); TagBuilder.AddStyle(form, "display:none;"); TagBuilder.AddClass(form, ConfigBuilder.GetFormPanelCssClass(this.Config)); TagBuilder.Close(form); TagBuilder.Begin(form, "div"); TagBuilder.AddClass(form, ConfigBuilder.GetFormCssClass(this.Config)); TagBuilder.Close(form); TagBuilder.Begin(form, "div"); TagBuilder.AddClass(form, ConfigBuilder.GetFormDescriptionCssClass(this.Config)); TagBuilder.Close(form); form.Append(Resources.Titles.RequiredFieldDetails); TagBuilder.EndTag(form, "div"); TagBuilder.Begin(form, "table"); TagBuilder.AddAttribute(form, "role", "scrud"); TagBuilder.Close(form); IEnumerable <FieldConfig> fields = FieldConfigHelper.GetFields(this.Values, this.Config, this.Editing); foreach (Field field in fields.Select(fieldConfig => new Field(this.Config, fieldConfig))) { form.Append(field.Get()); } FormFooter footer = new FormFooter(this.Config); form.Append(footer.Get()); TagBuilder.EndTag(form, "table"); TagBuilder.EndTag(form, "div"); TagBuilder.EndTag(form, "form"); return(form.ToString()); }
public override string Get() { GridView grid = new GridView(this.Config); StringBuilder gridPanel = new StringBuilder(); TagBuilder.Begin(gridPanel, "div"); TagBuilder.AddId(gridPanel, "GridPanel"); TagBuilder.AddClass(gridPanel, ConfigBuilder.GetGridPanelCssClass(this.Config)); TagBuilder.AddStyle(gridPanel, ConfigBuilder.GetGridPanelStyle(this.Config)); TagBuilder.Close(gridPanel); gridPanel.Append(grid.Get()); Pager pager = new Pager(this.Config); gridPanel.Append(pager.Get()); TagBuilder.EndTag(gridPanel, "div"); return(gridPanel.ToString()); }
public override string Get() { StringBuilder selector = new StringBuilder(); TagBuilder.Begin(selector, "a"); TagBuilder.AddClass(selector, this.CssClass); TagBuilder.AddAttribute(selector, "role", this.HtmlRole); TagBuilder.AddAttribute(selector, "tabindex", this.TabIndex); TagBuilder.AddAttribute(selector, "data-title", this.FieldConfig.ColumnNameLocalized); TagBuilder.AddAttribute(selector, "href", this.HRef); if (this.FieldConfig.IsDisabled) { TagBuilder.AddStyle(selector, "pointer-events:none;"); } TagBuilder.Close(selector); TagBuilder.EndTag(selector, "a"); return(selector.ToString()); }
public async override Task RenderAsync(TextWriter writer) { var tagName = "input"; if (TextMode == TextBoxMode.MultiLine) { tagName = "textarea"; } var tagBuilder = new TagBuilder(tagName) { TagRenderMode = TagRenderMode.SelfClosing }; tagBuilder.Attributes.Add("name", Name); switch (TextMode) { case TextBoxMode.SingleLine: tagBuilder.Attributes.Add("type", "text"); break; case TextBoxMode.MultiLine: if (Columns > 0) { tagBuilder.Attributes.Add("cols", Columns.ToString()); } if (Rows > 0) { tagBuilder.Attributes.Add("rows", Rows.ToString()); } break; case TextBoxMode.Password: tagBuilder.Attributes.Add("type", "password"); break; } tagBuilder.Attributes.Add("value", Text); if (!Visible) { tagBuilder.AddStyle( new Style { Attribute = "display", Value = "none" }); } if (BorderWidth > 0) { tagBuilder.AddStyle( new Style { Attribute = "border-width", Value = $"{BorderWidth}px" }); } if (BorderStyle > BorderStyle.None) { tagBuilder.AddStyle( new Style { Attribute = "border-style", Value = BorderStyle.ToString().ToLower() }); } if (!string.IsNullOrEmpty(BorderColor)) { tagBuilder.AddStyle( new Style { Attribute = "border-color", Value = BorderColor }); } if (!string.IsNullOrEmpty(BackColor)) { tagBuilder.AddStyle( new Style { Attribute = "background-color", Value = BackColor }); } if (!string.IsNullOrEmpty(ForeColor)) { tagBuilder.AddStyle( new Style { Attribute = "color", Value = ForeColor }); } if (!string.IsNullOrEmpty(CssClass)) { tagBuilder.AddCssClass(CssClass); } if (!Enabled) { tagBuilder.Attributes.Add("disabled", "disabled"); } if (Height > 0) { tagBuilder.AddStyle( new Style { Attribute = "hidth", Value = $"{Height}px" }); } if (Width > 0) { tagBuilder.AddStyle( new Style { Attribute = "width", Value = $"{Width}px" }); } if (!string.IsNullOrEmpty(ToolTip)) { tagBuilder.Attributes.Add("title", ToolTip); } if (Font != null) { if (!string.IsNullOrEmpty(Font.Name)) { tagBuilder.AddStyle( new Style { Attribute = "font-family", Value = Font.Name }); } if (Font.Size > 0) { tagBuilder.AddStyle( new Style { Attribute = "font-size", Value = $"{Font.Size}px" }); } if (Font.Bold) { tagBuilder.AddStyle( new Style { Attribute = "font-weight", Value = "bold" }); } if (Font.Italic) { tagBuilder.AddStyle( new Style { Attribute = "font-style", Value = "italic" }); } if (Font.Underline) { tagBuilder.AddStyle( new Style { Attribute = "text-decoration", Value = "underline" }); } if (Font.Stirkeout) { tagBuilder.AddStyle( new Style { Attribute = "text-decoration", Value = "line-throug" }); } } if (ReadOnly) { tagBuilder.Attributes.Add("readonly", "readonly"); } if (AutoPostBack) { tagBuilder.Attributes.Add("onchange", "this.form.submit()"); } tagBuilder.WriteTo(writer, HtmlEncoder.Default); await Task.CompletedTask; }
public async override Task RenderAsync(TextWriter writer) { var tagBuilder = new TagBuilder("input") { TagRenderMode = TagRenderMode.SelfClosing }; tagBuilder.Attributes.Add("name", Name); tagBuilder.Attributes.Add("type", "submit"); tagBuilder.Attributes.Add("value", Text); if (!Visible) { tagBuilder.AddStyle( new Style { Attribute = "display", Value = "none" }); } if (BorderWidth > 0) { tagBuilder.AddStyle( new Style { Attribute = "border-width", Value = $"{BorderWidth}px" }); } if (BorderStyle > BorderStyle.None) { tagBuilder.AddStyle( new Style { Attribute = "border-style", Value = BorderStyle.ToString().ToLower() }); } if (!string.IsNullOrEmpty(BorderColor)) { tagBuilder.AddStyle( new Style { Attribute = "border-color", Value = BorderColor }); } if (!string.IsNullOrEmpty(BackColor)) { tagBuilder.AddStyle( new Style { Attribute = "background-color", Value = BackColor }); } if (!string.IsNullOrEmpty(ForeColor)) { tagBuilder.AddStyle( new Style { Attribute = "color", Value = ForeColor }); } if (!string.IsNullOrEmpty(CssClass)) { tagBuilder.AddCssClass(CssClass); } if (!Enabled) { tagBuilder.Attributes.Add("disabled", "disabled"); } if (Height > 0) { tagBuilder.AddStyle( new Style { Attribute = "hidth", Value = $"{Height}px" }); } if (Width > 0) { tagBuilder.AddStyle( new Style { Attribute = "width", Value = $"{Width}px" }); } if (!string.IsNullOrEmpty(ToolTip)) { tagBuilder.Attributes.Add("title", ToolTip); } if (Font != null) { if (!string.IsNullOrEmpty(Font.Name)) { tagBuilder.AddStyle( new Style { Attribute = "font-family", Value = Font.Name }); } if (Font.Size > 0) { tagBuilder.AddStyle( new Style { Attribute = "font-size", Value = $"{Font.Size}px" }); } if (Font.Bold) { tagBuilder.AddStyle( new Style { Attribute = "font-weight", Value = "bold" }); } if (Font.Italic) { tagBuilder.AddStyle( new Style { Attribute = "font-style", Value = "italic" }); } if (Font.Underline) { tagBuilder.AddStyle( new Style { Attribute = "text-decoration", Value = "underline" }); } if (Font.Stirkeout) { tagBuilder.AddStyle( new Style { Attribute = "text-decoration", Value = "line-throug" }); } } if (!string.IsNullOrEmpty(CommandName)) { tagBuilder.Attributes.Add("data-commandName", CommandName); } if (!string.IsNullOrEmpty(CommandArgument)) { tagBuilder.Attributes.Add("data-commandArgument", CommandArgument); } tagBuilder.WriteTo(writer, HtmlEncoder.Default); await Task.CompletedTask; }