private static BootstrapModal BeginModalHelper(this HtmlHelper html, string dialogId, string dialogTitle, Object dialogHtmlAttributes, Object bodyHtmlAttributes, BootstrapModalButtons buttons) { TagBuilder tag = new TagBuilder("div"); tag.Attributes.Add("class", "modal hide fade"); tag.Attributes.Add("role", "dialog"); if (!String.IsNullOrEmpty(dialogId)) { tag.Attributes.Add("id", dialogId); } // Add any extra attributes to the dialog tag.AddAttributes(dialogHtmlAttributes); // Write out the initial div html.ViewContext.Writer.Write(tag.ToString(TagRenderMode.StartTag)); // Write out the header start TagBuilder headerTag = new TagBuilder("div"); headerTag.Attributes.Add("class", "modal-header"); html.ViewContext.Writer.Write(headerTag.ToString(TagRenderMode.StartTag)); // Write out the close button TagBuilder closeTag = new TagBuilder("button"); closeTag.Attributes.Add("type", "button"); closeTag.Attributes.Add("class", "close"); closeTag.Attributes.Add("data-dismiss", "modal"); closeTag.Attributes.Add("aria-hidden", "true"); closeTag.SetInnerText("x"); html.ViewContext.Writer.Write(closeTag.ToString(TagRenderMode.Normal)); // Write out the header if (!String.IsNullOrEmpty(dialogTitle)) { TagBuilder h3Tag = new TagBuilder("h3"); h3Tag.SetInnerText(dialogTitle); html.ViewContext.Writer.Write(h3Tag.ToString(TagRenderMode.Normal)); } // Finish off the header tag html.ViewContext.Writer.Write(headerTag.ToString(TagRenderMode.EndTag)); // Write out the body start TagBuilder bodyTag = new TagBuilder("div"); bodyTag.Attributes.Add("class", "modal-body"); // Add any extra attributes to the body bodyTag.AddAttributes(bodyHtmlAttributes); html.ViewContext.Writer.Write(bodyTag.ToString(TagRenderMode.StartTag)); // Finish off when the BootstrapModal object is disposed return(new BootstrapModal(html.ViewContext, buttons)); }