private static void EnsureDialog(string titleText) { if (ModalDialog == null) { ModalDialog = Make(titleText, "content", "myModal"); } }
private static void OnHidden() { if (ModalDialog != null) { ModalDialog.Remove(); ModalDialog = null; } }
private static void EnsureDialog(string titleText) { if (ModalDialog == null) ModalDialog = Make(titleText, "content", "myModal"); }
public static ModalDlg Make(string titleText, string bodyText, string id) { DivElement myModal = new DivElement(); myModal.ClassName = "modal fade"; myModal.Id = id; myModal.SetAttribute("role", "dialog"); jQuery jq = new jQuery(myModal).On("hidden.bs.modal", OnHidden); DivElement modalDlg = new DivElement(); modalDlg.ClassName = "modal-dialog-sm"; myModal.AppendChild(modalDlg); DivElement modalContent = new DivElement(); modalContent.ClassName = "modal-content"; modalDlg.AppendChild(modalContent); DivElement modalHeader = new DivElement(); modalHeader.ClassName = "modal-header"; modalContent.AppendChild(modalHeader); ButtonElement button = new ButtonElement(); button.SetAttribute("type", "button"); button.ClassName = "close"; button.SetAttribute("data-dismiss", "modal"); button.InnerHTML = "×"; modalHeader.AppendChild(button); HeadingElement title = new HeadingElement(HeadingType.H4); title.ClassName = "modal-title"; title.InnerHTML = titleText; modalHeader.AppendChild(title); DivElement modalBody = new DivElement(); modalBody.ClassName = "modal-body"; modalContent.AppendChild(modalBody); ParagraphElement bodyContent = new ParagraphElement(); bodyContent.InnerHTML = bodyText; modalBody.AppendChild(bodyContent); DivElement footer = new DivElement(); footer.ClassName = "modal-footer"; ButtonElement footerButton = new ButtonElement(); footerButton.SetAttribute("type", "button"); footerButton.ClassName = "btn btn-default"; footerButton.SetAttribute("data-dismiss", "modal"); footerButton.InnerHTML = "Close"; footer.AppendChild(footerButton); modalContent.AppendChild(footer); Document.Body.AppendChild(myModal); ModalDlg dlg = new ModalDlg(); dlg.TopElement = myModal; dlg.Body = modalBody; dlg.Title = title; dlg.BodyContent = bodyContent; dlg.Footer = footer; dlg.id = id; return dlg; }
public static ModalDlg Make(string titleText, string bodyText, string id) { DivElement myModal = new DivElement(); myModal.ClassName = "modal fade"; myModal.Id = id; myModal.SetAttribute("role", "dialog"); jQuery jq = new jQuery(myModal).On("hidden.bs.modal", OnHidden); DivElement modalDlg = new DivElement(); modalDlg.ClassName = "modal-dialog-sm"; myModal.AppendChild(modalDlg); DivElement modalContent = new DivElement(); modalContent.ClassName = "modal-content"; modalDlg.AppendChild(modalContent); DivElement modalHeader = new DivElement(); modalHeader.ClassName = "modal-header"; modalContent.AppendChild(modalHeader); ButtonElement button = new ButtonElement(); button.SetAttribute("type", "button"); button.ClassName = "close"; button.SetAttribute("data-dismiss", "modal"); button.InnerHTML = "×"; modalHeader.AppendChild(button); HeadingElement title = new HeadingElement(HeadingType.H4); title.ClassName = "modal-title"; title.InnerHTML = titleText; modalHeader.AppendChild(title); DivElement modalBody = new DivElement(); modalBody.ClassName = "modal-body"; modalContent.AppendChild(modalBody); ParagraphElement bodyContent = new ParagraphElement(); bodyContent.InnerHTML = bodyText; modalBody.AppendChild(bodyContent); DivElement footer = new DivElement(); footer.ClassName = "modal-footer"; ButtonElement footerButton = new ButtonElement(); footerButton.SetAttribute("type", "button"); footerButton.ClassName = "btn btn-default"; footerButton.SetAttribute("data-dismiss", "modal"); footerButton.InnerHTML = "Close"; footer.AppendChild(footerButton); modalContent.AppendChild(footer); Document.Body.AppendChild(myModal); ModalDlg dlg = new ModalDlg(); dlg.TopElement = myModal; dlg.Body = modalBody; dlg.Title = title; dlg.BodyContent = bodyContent; dlg.Footer = footer; dlg.id = id; return(dlg); }