Beispiel #1
0
        private static BootstrapAlert BeginAlertHelper(this HtmlHelper html, string alertClassName, string title, string id, string className)
        {
            TagBuilder tag = new TagBuilder("div");

            tag.AddOrMergeAttribute("class", "alert");

            if (!String.IsNullOrEmpty(alertClassName))
            {
                tag.AddOrMergeAttribute("class", alertClassName);
            }

            if (!String.IsNullOrEmpty(className))
            {
                tag.AddOrMergeAttribute("class", className);
            }

            if (!String.IsNullOrEmpty(id))
            {
                tag.Attributes.Add("id", id);
            }

            html.ViewContext.Writer.Write(tag.ToString(TagRenderMode.StartTag));

            if (!String.IsNullOrEmpty(title))
            {
                TagBuilder titleTag = new TagBuilder("h4");
                titleTag.MergeAttribute("class", "alert-heading");
                titleTag.SetInnerText(title);
                html.ViewContext.Writer.Write(titleTag.ToString(TagRenderMode.Normal));
            }

            BootstrapAlert theAlert = new BootstrapAlert(html.ViewContext);

            return(theAlert);
        }
        public static MvcHtmlString ShowDialog(this HtmlHelper html, string dialogId, string text, string className)
        {
            TagBuilder tag = new TagBuilder("a");

            tag.Attributes.Add("href", "#" + dialogId);
            tag.Attributes.Add("data-toggle", "modal");

            if (!String.IsNullOrEmpty(className))
            {
                tag.AddOrMergeAttribute("class", className);
            }

            tag.SetInnerText(text);

            return(new MvcHtmlString(tag.ToString(TagRenderMode.Normal)));
        }
        public static NavLi BeginBootstrapNavLi <TModel>(this HtmlHelper <TModel> html, string navGroupName, string className)
        {
            TagBuilder tag = new TagBuilder("li");

            if (html.ViewContext.Controller.ViewBag.CurrentNavGroup == navGroupName)
            {
                tag.Attributes.Add("class", "active");
            }

            if (!String.IsNullOrEmpty(className))
            {
                tag.AddOrMergeAttribute("class", className);
            }

            html.ViewContext.Writer.Write(tag.ToString(TagRenderMode.StartTag));

            return(new NavLi(html.ViewContext));
        }