/// <summary> /// In HTML konvertieren /// </summary> /// <returns>Das Control als HTML</returns> public override IHtmlNode ToHtml() { var classes = new List <string>(); classes.Add(Class); classes.Add("dropdown"); var buttonClasses = new List <string>(); buttonClasses.Add(ClassButton); buttonClasses.Add("btn"); if (Outline) { switch (Layout) { case TypesLayoutButton.Primary: buttonClasses.Add("btn-outline-primary"); break; case TypesLayoutButton.Success: buttonClasses.Add("btn-outline-success"); break; case TypesLayoutButton.Info: buttonClasses.Add("btn-outline-info"); break; case TypesLayoutButton.Warning: buttonClasses.Add("btn-outline-warning"); break; case TypesLayoutButton.Danger: buttonClasses.Add("btn-outline-danger"); break; case TypesLayoutButton.Light: buttonClasses.Add("btn-outline-light"); break; case TypesLayoutButton.Dark: buttonClasses.Add("btn-outline-dark"); break; } } else { switch (Layout) { case TypesLayoutButton.Primary: buttonClasses.Add("btn-primary"); break; case TypesLayoutButton.Success: buttonClasses.Add("btn-success"); break; case TypesLayoutButton.Info: buttonClasses.Add("btn-info"); break; case TypesLayoutButton.Warning: buttonClasses.Add("btn-warning"); break; case TypesLayoutButton.Danger: buttonClasses.Add("btn-danger"); break; case TypesLayoutButton.Light: buttonClasses.Add("btn-light"); break; case TypesLayoutButton.Dark: buttonClasses.Add("btn-dark"); break; } } switch (Size) { case TypesSize.Large: buttonClasses.Add("btn-lg"); break; case TypesSize.Small: buttonClasses.Add("btn-sm"); break; } switch (HorizontalAlignment) { case TypesHorizontalAlignment.Left: classes.Add("float-left"); break; case TypesHorizontalAlignment.Right: classes.Add("float-right"); break; } if (Block) { buttonClasses.Add("btn-block"); } var html = new HtmlElementDiv() { ID = ID, Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Style = Style }; var button = new HtmlElementButton() { ID = string.IsNullOrWhiteSpace(ID) ? "" : ID + "_btn", Class = string.Join(" ", buttonClasses.Where(x => !string.IsNullOrWhiteSpace(x))), Style = StyleButton, DataToggle = "dropdown" }; if (!string.IsNullOrWhiteSpace(Icon) && !string.IsNullOrWhiteSpace(Text)) { button.Elements.Add(new HtmlElementSpan() { Class = Icon }); button.Elements.Add(new HtmlNbsp()); button.Elements.Add(new HtmlNbsp()); button.Elements.Add(new HtmlNbsp()); } else if (!string.IsNullOrWhiteSpace(Icon) && string.IsNullOrWhiteSpace(Text)) { button.AddClass(Icon); } if (!string.IsNullOrWhiteSpace(Text)) { button.Elements.Add(new HtmlText(Text)); } html.Elements.Add(button); html.Elements.Add ( new HtmlElementUl ( Items.Select ( x => x == null ? new HtmlElementLi() { Class = "dropdown-divider", Inline = true } : x is ControlDropdownMenuHeader ? x.ToHtml() : new HtmlElementLi(x.ToHtml().AddClass("dropdown-item")) { } ) ) { Class = HorizontalAlignment == TypesHorizontalAlignment.Right ? "dropdown-menu dropdown-menu-right" : "dropdown-menu" } ); return(html); }
/// <summary> /// In HTML konvertieren /// </summary> /// <returns>Das Control als HTML</returns> public override IHtmlNode ToHtml() { if (Page.HasParam(Name)) { Value = Page.GetParam(Name); var value = Page.GetParam(Name); if (!string.IsNullOrWhiteSpace(Value) && value == Value) { OnClickEvent(new EventArgs()); } } var classes = new List <string>(); classes.Add(Class); classes.Add("btn"); if (Outline) { switch (Layout) { case TypesLayoutButton.Primary: classes.Add("btn-outline-primary"); break; case TypesLayoutButton.Success: classes.Add("btn-outline-success"); break; case TypesLayoutButton.Info: classes.Add("btn-outline-info"); break; case TypesLayoutButton.Warning: classes.Add("btn-outline-warning"); break; case TypesLayoutButton.Danger: classes.Add("btn-outline-danger"); break; case TypesLayoutButton.Dark: classes.Add("btn-outline-dark"); break; } } else { switch (Layout) { case TypesLayoutButton.Primary: classes.Add("btn-primary"); break; case TypesLayoutButton.Success: classes.Add("btn-success"); break; case TypesLayoutButton.Info: classes.Add("btn-info"); break; case TypesLayoutButton.Warning: classes.Add("btn-warning"); break; case TypesLayoutButton.Danger: classes.Add("btn-danger"); break; case TypesLayoutButton.Light: classes.Add("btn-light"); break; case TypesLayoutButton.Dark: classes.Add("btn-dark"); break; } } switch (Size) { case TypesSize.Large: classes.Add("btn-lg"); break; case TypesSize.Small: classes.Add("btn-sm"); break; } switch (HorizontalAlignment) { case TypesHorizontalAlignment.Left: classes.Add("float-left"); break; case TypesHorizontalAlignment.Right: classes.Add("float-right"); break; } if (Block) { classes.Add("btn-block"); } var html = new HtmlElementButton() { Name = Name, Type = Type, Value = Value, Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Role = Role, Disabled = Disabled }; if (!string.IsNullOrWhiteSpace(Icon) && !string.IsNullOrWhiteSpace(Text)) { html.Elements.Add(new HtmlElementSpan() { Class = Icon }); html.Elements.Add(new HtmlNbsp()); html.Elements.Add(new HtmlNbsp()); html.Elements.Add(new HtmlNbsp()); } else if (!string.IsNullOrWhiteSpace(Icon) && string.IsNullOrWhiteSpace(Text)) { html.AddClass(Icon); } if (!string.IsNullOrWhiteSpace(Text)) { html.Elements.Add(new HtmlText(Text)); } if (Content.Count > 0) { html.Elements.AddRange(Content.Select(x => x.ToHtml())); } return(html); }