private void CreateActionMenu(HtmlContainerControl menuContainer, IList <DataRow> responses, bool isNew) { menuContainer.Controls.Clear(); new HtmlSpan { InnerText = "Select action:" }.AddTo(menuContainer); var dropdown = new HtmlSelect().AddTo(menuContainer); var edit = dropdown.AddItem("Edit this response", "edit"); var add = dropdown.AddItem("Add another response to this question", "add"); var view = dropdown.AddItem("View or edit other responses to this question", "view"); if (responses.Count == 0) { menuContainer.AddCssClasses("hidden"); } else { menuContainer.RemoveCssClass("hidden"); } if (isNew && responses.Count > 0) { edit.Attributes.Add("disabled", "disabled"); add.Attributes.Add("selected", "selected"); } else { edit.Attributes.Add("selected", "selected"); if (responses.Count < 2) { view.Attributes.Add("disabled", "disabled"); } } }
// ReSharper restore UnusedMethodReturnValue.Global // ReSharper restore UnusedMember.Global // ReSharper restore MemberCanBeProtected.Global // ReSharper restore MemberCanBePrivate.Global #endregion Public #region Event handlers and overrides protected void Page_Load(object sender, EventArgs e) { Feedback.Controls.Clear(); FeedbackContainerOuter.Style.Add(HtmlTextWriterStyle.Display, "none"); var onclick = "$('#" + FeedbackContainerOuter.ClientID + "').hide(400);"; if (HasPlaceholder) { _PlaceholderTag = new HtmlP(); _PlaceholderTag.AddCssClasses("feedback-placeholder"); _PlaceholderTag.InnerHtml = Placeholder; _PlaceholderTag.ID = "Placeholder"; FeedbackContainerOuter.AddAfter(_PlaceholderTag); onclick += "$('#" + _PlaceholderTag.ClientID + "').show(400);"; } if (!string.IsNullOrWhiteSpace(CssClass)) { FeedbackContainerOuter.AddCssClasses(CssClass); } FeedbackHider.Attributes.Add("onclick", onclick); ValidationErrorCount = 0; }
public void CreateControls(HtmlContainerControl parent, IList <AnswersViewRow> responses, MonitorInstance monitor, Dictionary <string, string> alternateHeadings = null) { var row = responses.First(); var responsesAsDataRow = responses.Where(r => r.Sequence != null).Cast <DataRow>().ToList(); parent.AddCssClasses("answer-panel " + (_Usage == Usage.ForIssues ? "issues-answer-panel " : "intro-answer-panel ") + (SecurePage.IsPoliticianUser ? "politician-answer-panel" : "master-answer-panel")); // The panel title var heading = SecurePage.AddContainer(parent, null, null); var headingText = alternateHeadings != null && alternateHeadings.ContainsKey(row.QuestionKey) ? alternateHeadings[row.QuestionKey] : row.Question; SecurePage.AddHeading(heading, 4, null, null, headingText); SecurePage.Center(heading, true, true, "heading"); if (_Usage == Usage.ForIssues) { heading.Visible = false; } // Add undo button as next sibling to heading var undo = SecurePage.CreateUndoButton("Undo" + row.QuestionKey, monitor.GetUndoClass(null), $"Revert \"{row.Question}\" to the latest saved version"); heading.AddAfter(undo); // Same for clear button var clear = SecurePage.CreateClearButton("Clear" + row.QuestionKey, monitor.GetClearClass(null), $"Clear \"{row.Question}\""); heading.AddAfter(clear); var updatePanel = SecurePage.AddAjaxUpdatePanel(parent, "UpdatePanel" + row.QuestionKey); var container = SecurePage.AddContainer(updatePanel.ContentTemplateContainer, "Container" + row.QuestionKey, monitor.GetContainerClass("update-all updated answer-container")); SecurePage.AddHiddenField(container, "Description" + row.QuestionKey, monitor.GetDescriptionClass(null, "answer"), row.Question); SecurePage.AddHiddenField(container, "SubTab" + row.QuestionKey, "subtab subtab-" + row.QuestionKey); var hasNoResponses = row.Sequence == null; var sequenceItem = SecurePage.AddHiddenField(container, "Sequence" + row.QuestionKey, "answer-sequence", hasNoResponses ? "?" : row.Sequence.Value.ToString(CultureInfo.InvariantCulture)); SetResponseData(responsesAsDataRow, row, sequenceItem); // the action menu var menuContainer = SecurePage.AddContainer(container, "Action" + row.QuestionKey, "action-menu"); CreateActionMenu(menuContainer, responsesAsDataRow, row.Sequence == null); new HtmlP { InnerHtml = "To completely delete a response (Text and YouTube), use the Clear button (red <span>X</span> upper right) then Update." }.AddTo(container, "delete-message"); var subTabs = new HtmlDiv { ID = "answer-subtabs-" + row.QuestionKey, ClientIDMode = ClientIDMode.Static }.AddTo(container, "answer-sub-tabs shadow"); var subTabsTabs = new HtmlUl().AddTo(subTabs, "htabs unselectable"); var textSubTab = new HtmlLi { EnableViewState = false }.AddTo(subTabsTabs, "tab htab"); new HtmlAnchor { HRef = "#tab-textanswer-" + row.QuestionKey, InnerHtml = "Text<br />Response", EnableViewState = false }.AddTo(textSubTab); var youTubeSubTab = new HtmlLi { EnableViewState = false }.AddTo(subTabsTabs, "tab htab"); new HtmlAnchor { HRef = "#tab-youtubeanswer-" + row.QuestionKey, InnerHtml = "YouTube<br />Response", EnableViewState = false }.AddTo(youTubeSubTab); var textSubTabContent = new HtmlDiv { ID = "tab-textanswer-" + row.QuestionKey, ClientIDMode = ClientIDMode.Static }.AddTo(subTabs); var youTubeSubTabContent = new HtmlDiv { ID = "tab-youtubeanswer-" + row.QuestionKey, ClientIDMode = ClientIDMode.Static }.AddTo(subTabs); string moreClasses; switch (_Usage) { case Usage.ForIntroReasons: moreClasses = "mc-mt-reasons"; break; case Usage.ForIntroBio: moreClasses = "mc-mt-bio2"; break; default: var tabPrefix = MonitorPrefix + "-" + MonitorTabPrefix + "-issue" + row.IssueKey; var superTabPrefix = MonitorPrefix + "-" + MonitorSuperTabPrefix + "-igroup" + row.IssueGroupKey; moreClasses = tabPrefix + " " + superTabPrefix; break; } SecurePage.AddHiddenField(container, "HasValue" + row.QuestionKey, monitor.GetDataClass(moreClasses, "hasvalue"), string.IsNullOrWhiteSpace(row.Answer) && string.IsNullOrWhiteSpace(row.YouTubeUrl) ? string.Empty : "Y"); CreateTextSubTabContent(textSubTabContent, row, moreClasses, monitor); CreateYouTubeSubTabContent(youTubeSubTabContent, row, moreClasses, monitor); new HtmlHr().AddTo(container); // feedback AddFeedbackWithIe7Floater(container, "Feedback" + row.QuestionKey, monitor.GetFeedbackClass(null)); // update button SecurePage.AddUpdateButtonInContainer(container, "Button" + row.QuestionKey, "update-button", monitor.GetButtonClass("update-button button-1"), $"Update \"{row.Question}\"", ButtonUpdate_OnClick); SecurePage.AddClearBoth(container); }