示例#1
0
        /// <summary>
        /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter"/> object, which writes the content to be rendered on the client.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> object that receives the server control content.</param>
        protected override void Render(HtmlTextWriter writer)
        {
            string paddingCss = "";

            if (_Padded)
            {
                paddingCss = " alert-block";
            }

            writer.Write("<div class=\"alert alert-" + _NotificationBoxType.ToString().ToLower() + paddingCss + "\">" + Environment.NewLine);

            if (_Heading != null && _Heading != string.Empty)
            {
                writer.Write("         <h4 class=\"alert-heading\">" + _Heading + "</h4>");
            }

            if (_Title != null && _Title != string.Empty)
            {
                writer.Write("         <strong>" + _Title + "</strong> ");
            }

            writer.Write(this.Text);

            writer.Write("</div>" + Environment.NewLine);
        }
示例#2
0
        /// <summary>
        /// Outputs server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object and stores tracing information about the control if tracing is enabled.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the control content.</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            if (this.Visible)
            {
                string alertType = NotificationBoxType.ToString().ToLower();

                bool showMessage = !string.IsNullOrWhiteSpace(Heading) || !string.IsNullOrWhiteSpace(Title) || !string.IsNullOrWhiteSpace(this.Text);

                if (showMessage)
                {
                    writer.AddAttribute("class", string.Format("alert alert-{0} {1}", alertType, CssClass));
                    writer.AddAttribute("id", this.ClientID);
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);

                    if (this.Dismissable)
                    {
                        writer.Write(@"<button type='button' class='close' data-dismiss='alert' aria-hidden='true'><i class='fa fa-times'></i></button>");
                    }

                    if (!string.IsNullOrWhiteSpace(this.Heading))
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Strong);
                        writer.Write(Heading);
                        writer.RenderEndTag();
                    }

                    if (!string.IsNullOrWhiteSpace(this.Title))
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Strong);
                        writer.Write(Title + " ");
                        writer.RenderEndTag();
                    }

                    base.RenderControl(writer);

                    if (!string.IsNullOrWhiteSpace(this.Details))
                    {
                        string detailsFormat = @"
<small>
    <a data-toggle='collapse' data-parent='#{1}' href='#error-details_{1}'>Show Details</a>
</small>
<div id='error-details_{1}' class='collapse'>
        <p class='margin-t-sm'>
        {0}
    </p>
</div>";
                        writer.Write(detailsFormat, this.Details, this.ClientID);
                    }

                    writer.RenderEndTag();
                }
            }
        }