public void Should_append_to_parent() { IHtmlNode parent = new HtmlElement("div"); IHtmlNode child = new HtmlElement("div"); child.AppendTo(parent); Assert.Contains(child, parent.Children); }
private void AppendCol(HtmlElement colgroup, string columnWidth, bool hidden) { if (hidden) return; var col = new HtmlElement("col",TagRenderMode.SelfClosing); if (columnWidth.HasValue()) { col.Css("width", columnWidth); } col.AppendTo(colgroup); }
public IHtmlNode CreateTable() { var table = new HtmlElement("table"); var colgroup = new HtmlElement("colgroup"); colgroup.AppendTo(table); foreach (var colData in colsData) { AppendCol(colgroup, colData.Width, colData.Hidden); } ApplyDecorators(table); return table; }
public IHtmlNode Create(GridPagerData section) { var div = new HtmlElement("div") .AddClass("t-page-i-of-n"); var page = new LiteralNode(section.PageText); page.AppendTo(div); var input = new HtmlElement("input", TagRenderMode.SelfClosing) .Attribute("type", "text") .Attribute("value", section.CurrentPage.ToString()); input.AppendTo(div); var of = new LiteralNode(string.Format(section.PageOfText, section.PageCount)); of.AppendTo(div); return div; }
public IHtmlNode Create(GridPagerData section) { var span = new HtmlElement("span") .AddClass("k-pager-input", "k-label"); var page = new LiteralNode(section.Messages.Page); page.AppendTo(span); var input = new HtmlElement("input", TagRenderMode.SelfClosing) .Attribute("type", "text") .AddClass("k-textbox") .Attribute("value", section.Page.ToString()); input.AppendTo(span); var of = new LiteralNode(string.Format(section.Messages.Of, section.TotalPages)); of.AppendTo(span); return span; }
public IHtmlNode Build() { IHtmlNode wrapper = new HtmlElement("div") .Attributes(Component.HtmlAttributes) .PrependClass(UIPrimitives.Widget, "t-datetimepicker"); IHtmlNode innerWrapper = new HtmlElement("div") .AddClass("t-picker-wrap") .AppendTo(wrapper); InputTag().AppendTo(innerWrapper); IHtmlNode buttonsWrapper = new HtmlElement("span").AddClass("t-select"); CalendarButtonTag().AppendTo(buttonsWrapper); TimeButtonTag().AppendTo(buttonsWrapper); buttonsWrapper.AppendTo(innerWrapper); return wrapper; }
public IHtmlNode InnerContentTag() { IHtmlNode root = new HtmlElement("div").AddClass("t-dropdown-wrap", UIPrimitives.DefaultState); string text = " "; var items = Component.Items; int selectedIndex = Component.SelectedIndex; if (items.Count > 0 && !(string.IsNullOrEmpty(items[selectedIndex].Text) || items[selectedIndex].Text.Trim().Length == 0)) { text = items[selectedIndex].Text; if (Component.Encoded) { text = HttpUtility.HtmlEncode(text); } } new HtmlElement("span") .AddClass("t-input") .Html(text) .AppendTo(root); IHtmlNode link = new HtmlElement("span").AddClass("t-select"); new HtmlElement("span") .AddClass(UIPrimitives.Icon, "t-arrow-down") .Html("select") .AppendTo(link); link.AppendTo(root); return root; }
public IHtmlNode InnerContentTag() { IHtmlNode root = new HtmlElement("div").AddClass("t-dropdown-wrap t-state-default"); IHtmlNode input = new HtmlElement("input", TagRenderMode.SelfClosing) .Attributes(new { type = "text"}) .ToggleAttribute("disabled", "disabled", !Component.Enabled) .ToggleClass("input-validation-error", !Component.IsValid()) .PrependClass(UIPrimitives.Input) .AppendTo(root); string name = string.Empty; if (Component.Name.HasValue()) { name = Component.GetName("-input"); } string text = Component.GetValue<string>(Component.Value); if (!Component.Items.Any()) { text = Component.GetValue<string>(name, null); if (string.IsNullOrEmpty(text)) { try { text = Component.ViewContext.Controller.ValueOf<string>(name); } catch (System.Web.HttpRequestValidationException) { text = string.Empty; } } } else if (Component.SelectedIndex != -1) { text = Component.Items[Component.SelectedIndex].Text; if (Component.Encoded) { text = System.Web.HttpUtility.HtmlDecode(text); } } input.Attribute("id", Component.Id + "-input") .ToggleAttribute("name", name, name.HasValue()) .ToggleAttribute("value", text, text.HasValue()) .Attributes(Component.InputHtmlAttributes); IHtmlNode link = new HtmlElement("span").AddClass("t-select", UIPrimitives.Header); new HtmlElement("span").AddClass(UIPrimitives.Icon, "t-arrow-down").Html("select").AppendTo(link); link.AppendTo(root); return root; }