/// <summary> /// Constructor /// </summary> /// <param name="type">Type of alert</param> /// <param name="message">Alert message</param> /// <param name="title">Title/Heading of the alert</param> /// <param name="icon">Icon to be rendered with title/heading</param> /// <param name="htmlAttributes"> /// [Optional] Any extras HTML attributes to be applied. /// Note. These attributes are only applied to the top level div /// </param> public Alert(EMessage type, string message, string title, EBootstrapIcon?icon, object htmlAttributes = null) : base(EHtmlTag.Div, htmlAttributes) { IHtmlComponent i = (icon != null) ? BootstrapUtil.CreateIcon(icon.Value) : null; CreateAlert(type, message, title, i); }
private static string Render(IHtmlComponent component) { var textWriter = new StringWriter(); var writer = new HtmlTextWriter(textWriter); component.Render(writer); return textWriter.ToString(); }
/// <summary> /// Creates an alert /// </summary> /// <param name="type">Type of alert</param> /// <param name="message">Alert message</param> /// <param name="title">Title/Heading of the alert</param> /// <param name="icon">Icon to be rendered with title/heading</param> private void CreateAlert(EMessage type, string message, string title, IHtmlComponent icon) { CssClasses.Add(type.GetStringValue()); HtmlComponent bc = new HtmlComponent(EHtmlTag.B) { InnerHtml = title ?? string.Empty }; if (icon != null) { bc.PrependTags.Add(icon); } if (WebExtrasSettings.CssFramework != ECssFramework.JQueryUI) { CssClasses.Add("alert"); Button closeBtn = new Button(EButton.Regular, "×", string.Empty); closeBtn.CssClasses.Add("close"); closeBtn.Attributes["data-dismiss"] = "alert"; PrependTags.Add(closeBtn); PrependTags.Add(bc); InnerHtml = (!string.IsNullOrWhiteSpace(title) || icon != null) ? WebExtrasSettings.HTMLSpace + message : message; } else { HtmlComponent div = new HtmlComponent(EHtmlTag.Div); switch (type) { case EMessage.Error: div.CssClasses.Add("ui-state-error"); break; case EMessage.Information: case EMessage.Warning: div.CssClasses.Add("ui-state-highlight"); break; case EMessage.Success: div.CssClasses.Add("ui-state-success"); break; } div.CssClasses.Add("ui-corner-all"); div.PrependTags.Add(bc); div.InnerHtml = (!string.IsNullOrWhiteSpace(title) || icon != null) ? WebExtrasSettings.HTMLSpace + message : message; PrependTags.Add(div); } Type = type; }
private static string Render(IHtmlComponent component) { var textWriter = new StringWriter(); var writer = new HtmlTextWriter(textWriter); component.Render(writer); return(textWriter.ToString()); }
/// <summary> /// Constructor /// </summary> /// <param name="icon">Icon to be displayed as the hypelink</param> /// <param name="url">Link URL</param> /// <param name="htmlAttributes">[Optional Extra HTML attributes</param> public BootstrapIconlink(EFontAwesomeIcon icon, string url, object htmlAttributes = null) : base(string.Empty, url, htmlAttributes) { CssClasses.Add("icon-only-link"); m_icon = BootstrapUtil.CreateIcon(icon); PrependTags.Add(m_icon); }
/// <summary> /// Constructor /// </summary> /// <param name="icon">Icon to be displayed as the hypelink</param> /// <param name="url">Link URL</param> /// <param name="htmlAttributes">[Optional Extra HTML attributes</param> public BootstrapIconlink(EBootstrapIcon icon, string url, object htmlAttributes = null) : base(string.Empty, url, htmlAttributes) { CssClasses.Add("icon-only-link"); IHtmlComponent iconElement = BootstrapUtil.CreateIcon(icon); PrependTags.Add(iconElement); }
/// <summary> /// Init tag /// </summary> /// <param name="expression">The property lamba expression</param> /// <param name="htmlAttributes">Extra HTML attributes</param> private void Init(Expression <Func <TModel, TValue> > expression, object htmlAttributes) { Wrapper = new HtmlComponent(EHtmlTag.Div); RenderBehavior = WebExtrasSettings.FormControlBehavior; m_propertyExpression = expression.Body as MemberExpression; if (WebExtrasSettings.BootstrapVersion == EBootstrapVersion.V2) { CreateBootstrap2Tags(); } else { CreateBootstrap3Tags(htmlAttributes); } }
/// <summary> /// Constructor /// </summary> /// <param name="component">A HTML component to initialise with</param> public HtmlElement(IHtmlComponent component) { Component = component; }
/// <summary> /// Constructor /// </summary> /// <param name="component">A HTML component to initialise with</param> public ExtendedHtmlString(IHtmlComponent component) { Component = component; }
/// <summary> /// Converts current HTMl component to a <see cref="HtmlElement" /> /// </summary> /// <param name="component">Component to convert</param> /// <returns>Converted element</returns> public static HtmlElement ToHtmlElement(this IHtmlComponent component) { return(new HtmlElement(component)); }
/// <summary> /// Add html addon to the form control /// </summary> /// <param name="html">HTML to be added</param> /// <param name="append">[Optional] Whether to append or prepend the addon</param> /// <returns>The updated form control</returns> public IFormComponent <TModel, TValue> AddHtml(IHtmlComponent html, bool append = true) { return(CreateAddOn(html.ToHtml(), append)); }