/// <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("alert"); if (Dismissible) { classes.Add("alert-dismissible"); } if (Fade) { classes.Add("fade show"); } switch (Layout) { case TypesLayoutAlert.Success: classes.Add("alert-success"); break; case TypesLayoutAlert.Info: classes.Add("alert-info"); break; case TypesLayoutAlert.Warning: classes.Add("alert-warning"); break; case TypesLayoutAlert.Danger: classes.Add("alert-danger"); break; case TypesLayoutAlert.Light: classes.Add("alert-light"); break; case TypesLayoutAlert.Dark: classes.Add("alert-dark"); break; } var head = new HtmlElementStrong(new HtmlText(Head), new HtmlNbsp()); var button = new HtmlElementButton("×") { Class = "close" }; button.AddUserAttribute("data-dismiss", "alert"); button.AddUserAttribute("aria-label", "close"); button.AddUserAttribute("aria-hidden", "true"); return(new HtmlElementDiv(!string.IsNullOrWhiteSpace(Head) ? head : null, new HtmlText(Text), Dismissible ? button : null) { ID = ID, Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Style = Style, Role = "alert" }); }
/// <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("modal"); if (Fade) { classes.Add("fade"); } var headerText = new HtmlElementH4(Header) { Class = "modal-title" }; var headerButtonLabel = new HtmlElementSpan(new HtmlText("×")) { }; headerButtonLabel.AddUserAttribute("aria-hidden", "true"); var headerButton = new HtmlElementButton(headerButtonLabel) { Class = "close" }; headerButton.AddUserAttribute("aria-label", "close"); headerButton.AddUserAttribute("data-dismiss", "modal"); var header = new HtmlElementDiv(headerText, headerButton) { Class = "modal-header" }; var body = new HtmlElementDiv(from x in Content select x.ToHtml()) { Class = "modal-body" }; var footerButtonOK = new HtmlElementButton(new HtmlText("OK")) { Type = "submit", Class = "btn btn-success" }; //footerButtonOK.AddUserAttribute("data-dismiss", "modal"); var footerButtonCancel = new HtmlElementButton(new HtmlText("Abbrechen")) { Type = "button", Class = "btn btn-danger" }; footerButtonCancel.AddUserAttribute("data-dismiss", "modal"); var footer = new HtmlElementDiv(footerButtonOK, footerButtonCancel) { Class = "modal-footer" }; var form = new HtmlElementForm(header, body, footer) { Action = "#" + ID, Method = "post", Name = "form_" + ID }; var content = new HtmlElementDiv(form) { Class = "modal-content" }; var dialog = new HtmlElementDiv(content) { Class = "modal-dialog", Role = "document" }; var html = new HtmlElementDiv(dialog) { ID = ID, Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Style = Style, Role = "dialog" }; if (!string.IsNullOrWhiteSpace(OnShownCode)) { var shown = "$('#" + ID + "').on('shown.bs.modal', function(e) { " + OnShownCode + " });"; Page.AddScript(ID + "_shown", shown); } if (!string.IsNullOrWhiteSpace(OnHiddenCode)) { var hidden = "$('#" + ID + "').on('hidden.bs.modal', function() { " + OnHiddenCode + " });"; Page.AddScript(ID + "_hidden", hidden); } return(html); }
/// <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("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; } if (Block) { classes.Add("btn-block"); } switch (HorizontalAlignment) { case TypesHorizontalAlignment.Left: classes.Add("float-left"); break; case TypesHorizontalAlignment.Right: classes.Add("float-right"); break; } var html = new HtmlElementButton() { Text = Text, Type = "button", Value = Value, Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Role = Role, Disabled = Disabled }; if (Content.Count > 0) { html.Elements.AddRange(Content.Select(x => x.ToHtml())); } if (Modal != null) { html.AddUserAttribute("data-toggle", "modal"); html.AddUserAttribute("data-target", "#" + Modal.ID); return(new HtmlList(html, Modal.ToHtml())); } return(html); }