protected virtual void InitializeItem(TemplateControl owner, bool addMonitorClasses = true, FeedbackContainerControl feedback = null) { _GroupName = _GroupName.SafeString(); var monitorClasses = addMonitorClasses ? $"mc mc-group-{_GroupName}-{Column}" .ToLowerInvariant() : null; DataControl = FindControl(owner, "Control" + _GroupName + Column); // owner.Master.FindMainContentControl("Control" + _GroupName + Column); if (addMonitorClasses) { DataControl.AddCssClasses(monitorClasses + " mc-data"); } var tooltip = DataControlToolTip; if (!IsNullOrWhiteSpace(tooltip)) { DataControl.SetToolTip(tooltip); DataControl.AddCssClasses("tiptip"); } Feedback = feedback ?? FindControl(owner, "Feedback" + _GroupName) as // owner.Master.FindMainContentControl("Feedback" + _GroupName) as FeedbackContainerControl; _Asterisk = FindControl(owner, "Asterisk" + _GroupName + Column) as //owner.Master.FindMainContentControl("Asterisk" + _GroupName + Column) as HtmlControl; Label = FindControl(owner, "Label" + _GroupName + Column) as //owner.Master.FindMainContentControl("Label" + _GroupName + Column) as HtmlControl; if (_Asterisk != null) { if (addMonitorClasses) { _Asterisk.AddCssClasses(monitorClasses + " mc-ast"); } tooltip = AsteriskToolTip; if (!IsNullOrWhiteSpace(tooltip)) { _Asterisk.Attributes.Add("title", tooltip); _Asterisk.AddCssClasses("tiptip"); } } var expandable = FindControl(owner, "Expandable" + _GroupName + Column); //owner.Master.FindMainContentControl("Expandable" + _GroupName + Column); expandable?.AddCssClasses(monitorClasses + " mc-expandable"); }
public static HtmlControl AddTo(this HtmlControl control, Control parent, string classes = null, bool clear = false) { parent.Controls.Add(control); if (classes != null) { control.AddCssClasses(classes, clear); } return(control); }
private static void CreateAnswerControls(HtmlControl parent, IList <DataRow> responses, int duplicate) { var row = responses.First(); var responsesAsDataRow = responses.Where(r => r.SequenceOrNull() != null).ToList(); parent.AddCssClasses("answer-panel " + (IsPoliticianUser ? "politician-answer-panel" : "master-answer-panel")); var questionId = row.QuestionId(); var questionIdUnique = $"{questionId}-{duplicate}"; // The panel title var heading = AddContainer(parent, null, null); // Add undo button as next sibling to heading var undo = CreateUndoButton("Undo" + questionIdUnique, "undo" + questionId, $"Revert \"{row.Question()}\" to the latest saved version"); heading.AddAfter(undo); // Same for clear button var clear = CreateClearButton("Clear" + questionIdUnique, "clear" + questionId, $"Clear \"{row.Question()}\""); heading.AddAfter(clear); var container = AddContainer(parent, "Container" + questionIdUnique, $"container{questionId} update-all updated answer-container" ); container.Attributes.Add("data-id", questionId.ToString()); AddHiddenField(container, "Description" + questionIdUnique, "description" + questionId, row.Question()); AddHiddenField(container, "SubTab" + questionIdUnique, "subtab subtab-" + questionId); var hasNoResponses = row.SequenceOrNull() == null; var sequenceItem = AddHiddenField(container, "Sequence" + questionIdUnique, $"answer-sequence sequence{questionId}", hasNoResponses ? "?" : row.SequenceOrNull()?.ToString(CultureInfo.InvariantCulture)); SetResponseData(questionId, responsesAsDataRow, sequenceItem); // the action menu var menuOuter = new HtmlDiv().AddTo(container, "menu-outer"); var menuContainer = AddContainer(menuOuter, "Action" + questionIdUnique, $"action-menu action{questionId}"); CreateActionMenu2(menuContainer, responsesAsDataRow /*, row.SequenceOrNull() == null*/); new HtmlP { InnerHtml = "To completely delete a response (Text and YouTube Video), use the Clear button (red <span>X</span> upper right) then Save Changes." }.AddTo(container, "delete-message"); var subTabs = new HtmlDiv { ID = "answer-subtabs-" + questionIdUnique, ClientIDMode = ClientIDMode.Static }.AddTo(container, $"answer-subtabs-{questionId} 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-" + questionIdUnique, InnerHtml = "Text<br />Response", EnableViewState = false }.AddTo(textSubTab); var youTubeSubTab = new HtmlLi { EnableViewState = false }.AddTo(subTabsTabs, "tab htab"); new HtmlAnchor { HRef = "#tab-youtubeanswer-" + questionIdUnique, InnerHtml = "YouTube<br />Response", EnableViewState = false }.AddTo(youTubeSubTab); var textSubTabContent = new HtmlDiv { ID = "tab-textanswer-" + questionIdUnique, ClientIDMode = ClientIDMode.Static }.AddTo(subTabs, $"tab-textanswer-{questionId}"); var youTubeSubTabContent = new HtmlDiv { ID = "tab-youtubeanswer-" + questionIdUnique, ClientIDMode = ClientIDMode.Static }.AddTo(subTabs, $"tab-youtubeanswer-{questionId}"); AddHiddenField(container, "HasValue" + questionIdUnique, $"hasvalue{questionId}", IsNullOrWhiteSpace(row.Answer()) && IsNullOrWhiteSpace(row.YouTubeUrl()) && (IsNullOrWhiteSpace(row.FacebookVideoUrl()) || !AllowFacebookVideos) ? Empty : "Y"); CreateTextSubTabContent(textSubTabContent, row, duplicate); CreateYouTubeSubTabContent(youTubeSubTabContent, row, duplicate); AddClearBoth(container); }