Beispiel #1
0
        private static void EmbedFacebookVideo(Control container, string facebookVideoId, QuestionAndAnswer row,
                                               Control heading = null)
        {
            // uses fake Facebook player
            if (!IsNullOrWhiteSpace(facebookVideoId))
            {
                var videoWrapper = new HtmlDiv().AddTo(container, "video-container facebookvideo-container");
                var videoPlayer  = new HtmlDiv().AddTo(videoWrapper, "video-player facebookvideo-player");
                videoPlayer.Attributes.Add("data-type", "fb");
                videoPlayer.Attributes.Add("data-id", facebookVideoId);
            }
            heading?.AddTo(container);
            var description = FormatVideoDescription(row.FacebookVideoDescription, row.FacebookVideoRunningTime);
            var key         = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}";

            VotePage.GetMorePart1(description, MoreMinForVideo, MoreMaxForVideo,
                                  "fbdesc", key).AddTo(container);
            var sourceTag = new HtmlP().AddTo(container, "video-source");

            new HtmlSpan {
                InnerText = "Source: Uploaded by candidate "
            }.AddTo(sourceTag);
            if (!row.FacebookVideoDate.IsDefaultDate())
            {
                new LiteralControl("(" + row.FacebookVideoDate.ToString("M/d/yyyy") + ")").AddTo(
                    sourceTag);
            }
        }
        private static void PopulateIncumbentsToReinstateList(
            IEnumerable <IGrouping <string, DataRow> > incumbentsToReinstate,
            Control parent)
        {
            parent.Controls.Clear();

            var container = new HtmlDiv().AddTo(parent, "offices");

            foreach (var incumbents in incumbentsToReinstate)
            {
                var office = incumbents.First();
                var div    = new HtmlDiv().AddTo(container, "office");
                div.Attributes.Add("rel", office.OfficeKey());
                new HtmlP {
                    InnerHtml = Offices.FormatOfficeName(office)
                }
                .AddTo(div, "office-name");
                foreach (var incumbent in incumbents)
                {
                    var p = new HtmlP().AddTo(div);
                    new HtmlInputCheckBox
                    {
                        Checked = false,
                        Value   = incumbent.PoliticianKey()
                    }.AddTo(p, "incumbent");
                    new LiteralControl(Politicians.FormatName(incumbent)).AddTo(p);
                }
            }
        }
        public void Add(string cssClass, string feedback)
        {
            var p = new HtmlP();

            p.Attributes.Add("class", cssClass);
            p.InnerHtml = feedback;
            Feedback.Controls.Add(p);
            FeedbackContainerOuter.Style.Add(HtmlTextWriterStyle.Display, "");
            if (HasPlaceholder)
            {
                _PlaceholderTag.Style.Add(HtmlTextWriterStyle.Display, "none");
            }
        }
Beispiel #4
0
        //private static void EmbedVideo(Control container, string youTubeId, QuestionAndAnswer row,
        //  Control heading = null)
        //{
        //  if (!string.IsNullOrWhiteSpace(youTubeId))
        //  {
        //    var videoWrapper = new HtmlDiv().AddTo(container, "video-wrapper");
        //    var videoWrapperInner = new HtmlDiv().AddTo(videoWrapper, "video-wrapper-inner");
        //    var iframe = new HtmlGenericControl("iframe").AddTo(videoWrapperInner);
        //    iframe.Attributes.Add("width", "420");
        //    iframe.Attributes.Add("height", "236");
        //    iframe.Attributes.Add("src",
        //      "https://www.youtube.com/embed/" + youTubeId + "?rel=0&showinfo=0");
        //    iframe.Attributes.Add("frameborder", "0");
        //    iframe.Attributes.Add("allowfullscreen", "allowfullscreen");
        //  }
        //  if (heading != null) heading.AddTo(container);
        //  var description = FormatYouTubeDescription(row.YouTubeDescription, row.YouTubeRunningTime);
        //  var key = string.Format("{0}:{1}:{2}", row.PoliticianKey, row.QuestionKey, row.Sequence);
        //  VotePage.GetMorePart1(description, MoreMinForYouTube, MoreMaxForYouTube,
        //    "ytdesc", key).AddTo(container);
        //  if (!string.IsNullOrWhiteSpace(row.YouTubeSource) || row.YouTubeDate != VotePage.DefaultDbDate)
        //  {
        //    var sourceTag = new HtmlP().AddTo(container, "video-source");
        //    if (!string.IsNullOrWhiteSpace(row.YouTubeSource))
        //    {
        //      new HtmlSpan { InnerText = "Source: " }.AddTo(sourceTag);
        //      if (string.IsNullOrWhiteSpace(row.YouTubeSourceUrl))
        //        new LiteralControl(row.YouTubeSource).AddTo(sourceTag);
        //      else
        //        new HtmlAnchor
        //        {
        //          HRef = VotePage.NormalizeUrl(row.YouTubeSourceUrl),
        //          InnerHtml = row.YouTubeSource,
        //          Target = "view"
        //        }.AddTo(sourceTag);
        //      if (row.YouTubeDate != VotePage.DefaultDbDate)
        //        new LiteralControl(" ").AddTo(sourceTag);
        //    }
        //    if (row.YouTubeDate != VotePage.DefaultDbDate)
        //      new LiteralControl("(" + row.YouTubeDate.ToString("M/d/yyyy") + ")").AddTo(sourceTag);
        //  }
        //}

        private static void EmbedVideo2(Control container, string youTubeId, QuestionAndAnswer row,
                                        Control heading = null)
        {
            // uses fake YouTube player
            if (!string.IsNullOrWhiteSpace(youTubeId))
            {
                var videoWrapper = new HtmlDiv().AddTo(container, "youtube-container");
                new HtmlDiv().AddTo(videoWrapper, "youtube-player")
                .Attributes.Add("data-id", youTubeId);
                //var iframe = new HtmlGenericControl("iframe").AddTo(videoWrapperInner);
                //iframe.Attributes.Add("width", "420");
                //iframe.Attributes.Add("height", "236");
                //iframe.Attributes.Add("src",
                //  "https://www.youtube.com/embed/" + youTubeId + "?rel=0&showinfo=0");
                //iframe.Attributes.Add("frameborder", "0");
                //iframe.Attributes.Add("allowfullscreen", "allowfullscreen");
            }
            heading?.AddTo(container);
            var description = FormatYouTubeDescription(row.YouTubeDescription, row.YouTubeRunningTime);
            var key         = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}";

            VotePage.GetMorePart1(description, MoreMinForYouTube, MoreMaxForYouTube,
                                  "ytdesc", key).AddTo(container);
            if (!string.IsNullOrWhiteSpace(row.YouTubeSource) ||
                (row.YouTubeDate != VotePage.DefaultDbDate))
            {
                var sourceTag = new HtmlP().AddTo(container, "video-source");
                if (!string.IsNullOrWhiteSpace(row.YouTubeSource))
                {
                    new HtmlSpan {
                        InnerText = "Source: "
                    }.AddTo(sourceTag);
                    if (string.IsNullOrWhiteSpace(row.YouTubeSourceUrl))
                    {
                        new LiteralControl(row.YouTubeSource).AddTo(sourceTag);
                    }
                    else
                    {
                        new HtmlAnchor
                        {
                            HRef      = VotePage.NormalizeUrl(row.YouTubeSourceUrl),
                            InnerHtml = row.YouTubeSource,
                            Target    = "view"
                        }
                    }.AddTo(sourceTag);
        private static void PopulateIncumbentsToAdjustList(
            IEnumerable <IGrouping <string, DataRow> > incumbentsToEliminate,
            Control parent)
        {
            parent.Controls.Clear();

            new HtmlH6
            {
                InnerHtml =
                    "Incumbent(s) must be removed from the following office(s) to make room for newly elected candidate(s).<br />" +
                    "<em>If any incumbents won reelection, remove them here then mark them as winners on the </em>General Winners<em> tab.</em><br />" +
                    "<em>If no incumbents were running for reelection, remove the current office holder whose term is expiring.</em>"
            }.AddTo(parent);

            var container = new HtmlDiv().AddTo(parent, "offices");

            foreach (var incumbents in incumbentsToEliminate)
            {
                var office = incumbents.First();
                var div    = new HtmlDiv().AddTo(container, "office");
                div.Attributes.Add("rel", office.OfficeKey());
                new HtmlP {
                    InnerHtml = Offices.FormatOfficeName(office)
                }
                .AddTo(div, "office-name");
                var extra = office.ElectionPositions() -
                            (office.Incumbents() - incumbents.Count());
                new HtmlP
                {
                    InnerHtml = $"Eliminate {extra}"
                }
                .AddTo(div, "office-extra");
                foreach (var incumbent in incumbents)
                {
                    var p = new HtmlP().AddTo(div);
                    new HtmlInputCheckBox
                    {
                        Checked = true,
                        Value   = incumbent.PoliticianKey()
                    }.AddTo(p, "incumbent");
                    new LiteralControl(Politicians.FormatName(incumbent)).AddTo(p);
                }
            }
        }
Beispiel #6
0
        private void PopulateVideosList()
        {
            var videos = InstructionalVideos.GetAllData();

            AllVideos.InnerHtml = string.Join(string.Empty,
                                              videos
                                              .OrderBy(v => v.Title, StringComparer.OrdinalIgnoreCase)
                                              .Select(v =>
            {
                var p = new HtmlP {
                    InnerText = v.Title
                };
                p.Attributes.Add("data-id", v.Id.ToString(CultureInfo.InvariantCulture));
                p.Attributes.Add("data-url", v.Url);
                p.Attributes.Add("data-description", v.Description);
                p.Attributes.Add("data-embedcode", v.EmbedCode);
                return(p.RenderToString());
            }));
            AdminVideos.InnerHtml = string.Join(string.Empty,
                                                videos
                                                .Where(v => v.AdminOrder != 0)
                                                .OrderBy(v => v.AdminOrder)
                                                .Select(v =>
            {
                var p = new HtmlP {
                    InnerText = v.Title
                };
                p.Attributes.Add("data-id", v.Id.ToString(CultureInfo.InvariantCulture));
                return(p.RenderToString());
            }));
            VolunteersVideos.InnerHtml = string.Join(string.Empty,
                                                     videos
                                                     .Where(v => v.VolunteersOrder != 0)
                                                     .OrderBy(v => v.VolunteersOrder)
                                                     .Select(v =>
            {
                var p = new HtmlP {
                    InnerText = v.Title
                };
                p.Attributes.Add("data-id", v.Id.ToString(CultureInfo.InvariantCulture));
                return(p.RenderToString());
            }));
        }
 private void BuildStatesList(string singleState = null)
 {
     StatesPickerList.Controls.Clear();
     foreach (var stateCode in StateCache.All51StateCodes)
     {
         if (singleState == null || singleState == stateCode)
         {
             var stateName = StateCache.GetStateName(stateCode);
             var p         = new HtmlP().AddTo(StatesPickerList, "sub-label");
             p.Attributes["title"] = stateName;
             new HtmlInputCheckBox {
                 Value = stateCode, Checked = true
             }.AddTo(p);
             new HtmlSpan {
                 InnerHtml = stateName
             }.AddTo(p);
         }
     }
 }
        // ReSharper restore UnusedAutoPropertyAccessor.Global

        private void BuildCountiesList(string stateCode, string singleCounty = null)
        {
            CountiesPickerList.Controls.Clear();
            foreach (var countyCode in CountyCache.GetCountiesByState(stateCode))
            {
                if (singleCounty == null || singleCounty == countyCode)
                {
                    var countyName = CountyCache.GetCountyName(stateCode, countyCode);
                    var p          = new HtmlP().AddTo(CountiesPickerList, "sub-label");
                    p.Attributes["title"] = countyName;
                    new HtmlInputCheckBox {
                        Value = countyCode, Checked = true
                    }.AddTo(p);
                    new HtmlSpan {
                        InnerHtml = countyName
                    }.AddTo(p);
                }
            }
        }
        private void BuildLocalsList(string stateCode, string countyCode,
                                     string singleLocal = null)
        {
            var locals = LocalDistricts.GetNamesDictionary(stateCode, countyCode);

            LocalsPickerList.Controls.Clear();
            foreach (var local in locals.OrderBy(kvp => kvp.Value, new AlphanumericComparer()))
            {
                if (singleLocal == null || singleLocal == local.Key)
                {
                    var p = new HtmlP().AddTo(LocalsPickerList, "sub-label");
                    p.Attributes["title"] = local.Value;
                    new HtmlInputCheckBox {
                        Value = local.Key, Checked = true
                    }.AddTo(p);
                    new HtmlSpan {
                        InnerHtml = local.Value
                    }.AddTo(p);
                }
            }
        }
Beispiel #10
0
        private static void EmbedYouTube(Control container, string youTubeId, QuestionAndAnswer row,
                                         Control heading = null)
        {
            // uses fake YouTube player
            if (!IsNullOrWhiteSpace(youTubeId))
            {
                var videoWrapper = new HtmlDiv().AddTo(container, "video-container youtube-container");
                var videoPlayer  = new HtmlDiv().AddTo(videoWrapper, "video-player youtube-player");
                videoPlayer.Attributes.Add("data-type", "yt");
                videoPlayer.Attributes.Add("data-id", youTubeId);
            }
            heading?.AddTo(container);
            var description = FormatVideoDescription(row.YouTubeDescription, row.YouTubeRunningTime);
            var key         = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}";

            VotePage.GetMorePart1(description, MoreMinForVideo, MoreMaxForVideo,
                                  "ytdesc", key).AddTo(container);
            if (!IsNullOrWhiteSpace(row.YouTubeSource) || !row.YouTubeDate.IsDefaultDate())
            {
                var sourceTag = new HtmlP().AddTo(container, "video-source");
                if (!IsNullOrWhiteSpace(row.YouTubeSource))
                {
                    new HtmlSpan {
                        InnerText = "Source: "
                    }.AddTo(sourceTag);
                    if (IsNullOrWhiteSpace(row.YouTubeSourceUrl))
                    {
                        new LiteralControl(row.YouTubeSource).AddTo(sourceTag);
                    }
                    else
                    {
                        new HtmlAnchor
                        {
                            HRef      = VotePage.NormalizeUrl(row.YouTubeSourceUrl),
                            InnerHtml = row.YouTubeSource,
                            Target    = "view"
                        }
                    }.AddTo(sourceTag);
Beispiel #11
0
        protected static void FormatAnswer(DataRow answerRow, Control td, bool prependName)
        {
            const int maxLengthSource = 45;

            if (answerRow != null)
            {
                var div = new HtmlDiv().AddTo(td);
                if (!IsNullOrWhiteSpace(answerRow.Answer()))
                {
                    var answer = TruncateAnswer(answerRow.Answer());
                    if (prependName)
                    {
                        answer = PrependName(answerRow.LastName(), answer);
                    }
                    new LiteralControl(answer.ReplaceNewLinesWithParagraphs()).AddTo(div);
                    var answerSource = answerRow.AnswerSource()
                                       .SafeString();
                    var answerDate = answerRow.AnswerDate(VotePage.DefaultDbDate);
                    if (!IsNullOrWhiteSpace(answerSource) || !answerDate.IsDefaultDate())
                    {
                        var p = new HtmlP().AddTo(div);
                        if (!IsNullOrWhiteSpace(answerSource))
                        {
                            Debug.Assert(answerSource != null, "answerSource != null");
                            if (answerSource.Length > maxLengthSource)
                            {
                                var slashLocation = answerSource.IndexOf("/",
                                                                         StringComparison.Ordinal);
                                answerSource = slashLocation != -1
                  ? answerSource.Insert(slashLocation + 1, "<br />")
                  : answerSource.Insert(maxLengthSource, "<br />");
                            }
                            var span = new HtmlSpan().AddTo(p, "source");
                            new HtmlSpan {
                                InnerHtml = "Source: "
                            }.AddTo(span);
                            new LiteralControl(answerSource).AddTo(span);
                        }
                        if (!answerDate.IsDefaultDate())
                        {
                            new LiteralControl(" (" + answerDate.ToString("MM/dd/yyyy") + ")").AddTo(p);
                        }
                    }
                }
                if (!IsNullOrWhiteSpace(answerRow.YouTubeUrl()))
                {
                    var p      = new HtmlP().AddTo(div);
                    var anchor = new HtmlAnchor
                    {
                        HRef   = answerRow.YouTubeUrl(),
                        Target = "YouTube"
                    }.AddTo(p);
                    new HtmlImage {
                        Src = "/images/youTubeWide.jpg"
                    }.AddTo(anchor);
                    var youTubeDate = answerRow.YouTubeDate(VotePage.DefaultDbDate);
                    if (!youTubeDate.IsDefaultDate())
                    {
                        new HtmlSpan
                        {
                            InnerHtml = "(" + youTubeDate.ToString("MM/dd/yyyy") + ")"
                        }.AddTo(p, "youtubedate");
                    }
                }
            }
            if (td.Controls.Count == 0)
            {
                new HtmlNbsp().AddTo(td);
            }
        }
Beispiel #12
0
        private void BuildOneNagsDataRow(
            string editMode, int editMessageNumber, Control htmlTable,
            DonationNagsRow nagsRow)
        {
            var msgNo = nagsRow.MessageNumber.ToString(CultureInfo.InvariantCulture);

            var tr = new TableRow();

            htmlTable.Controls.Add(tr);

            // First operation column
            var tdAction1 = new TableCell();

            tr.Controls.Add(tdAction1);
            LinkButton button1;

            if (editMode == Empty)
            {
                button1 = new LinkButton();
                tdAction1.Controls.Add(button1);
                button1.CssClass = "op op-edit";
                button1.Text     = "Edit";
                button1.ID       = "Edit" + msgNo;
                button1.ToolTip  = "Edit Msg No " + msgNo;
                button1.Click   += EditButton_Click;
            }
            else if (editMode == "Edit" && editMessageNumber == nagsRow.MessageNumber)
            {
                button1 = new LinkButton();
                tdAction1.Controls.Add(button1);
                button1.CssClass = "op op-update";
                button1.Text     = "Update";
                button1.ToolTip  = "Save the changes to Msg No " + msgNo;
                button1.ID       = "Update" + msgNo;
                button1.Click   += UpdateButton_Click;
            }
            else
            {
                tdAction1.Text = "&nbsp;";
            }

            // Second operation column
            var tdAction2 = new TableCell();

            tr.Controls.Add(tdAction2);
            LinkButton button2;

            if (editMode == Empty)
            {
                button2 = new LinkButton();
                tdAction2.Controls.Add(button2);
                button2.CssClass = "op op-delete";
                button2.Text     = "Delete";
                button2.ID       = "Delete" + msgNo;
                button2.ToolTip  = "Delete Msg No " + msgNo;
                button2.Click   += DeleteButton_Click;
            }
            else if (editMode == "Edit" && editMessageNumber == nagsRow.MessageNumber)
            {
                button2 = new LinkButton();
                tdAction2.Controls.Add(button2);
                button2.CssClass = "op op-cancel";
                button2.Text     = "Cancel";
                button2.ID       = "Cancel" + msgNo;
                button2.ToolTip  = "Cancel editing Msg No " + msgNo +
                                   " -- no changes will be made";
                button2.Click += CancelButton_Click;
            }
            else
            {
                tdAction2.Text = "&nbsp;";
            }

            // Create data columns
            var tdMessageNumber = new TableCell();

            tr.Controls.Add(tdMessageNumber);
            tdMessageNumber.ID       = "MessageNumber" + msgNo;
            tdMessageNumber.CssClass = "content";

            var tdNextMessageNumber = new TableCell();

            tr.Controls.Add(tdNextMessageNumber);
            tdNextMessageNumber.ID       = "NextMessageNumber" + msgNo;
            tdNextMessageNumber.CssClass = "content";

            //var tdMessageHeading = new TableCell();
            //tr.Controls.Add(tdMessageHeading);
            //tdMessageHeading.ID = "MessageHeading" + msgNo;
            //tdMessageHeading.CssClass = "content";

            var tdMessageText = new TableCell();

            tr.Controls.Add(tdMessageText);
            tdMessageText.ID       = "MessageText" + msgNo;
            tdMessageText.CssClass = "content";

            // Populate data columns
            // If it's the actrive edit column, populate with TextBoxes
            if (editMode == "Edit" && editMessageNumber == nagsRow.MessageNumber)
            {
                TextBox tbMessageNumber = new TextBoxWithNormalizedLineBreaks();
                tdMessageNumber.Controls.Add(tbMessageNumber);
                tbMessageNumber.ID       = TextBoxMessageNumberId;
                tbMessageNumber.CssClass = "text-box message-number";

                tbMessageNumber.Text = msgNo;

                TextBox tbNextMessageNumber = new TextBoxWithNormalizedLineBreaks();
                tdNextMessageNumber.Controls.Add(tbNextMessageNumber);
                tbNextMessageNumber.ID = TextBoxNextMessageNumberId;

                tbNextMessageNumber.CssClass = "text-box next-message-number";

                tbNextMessageNumber.Text = nagsRow.NextMessageNumber == null
          ? Empty
          : nagsRow.NextMessageNumber.ToString();

                TextBox tbMessageText = new TextBoxWithNormalizedLineBreaks();
                tdMessageText.Controls.Add(tbMessageText);
                tbMessageText.ID = TextBoxMessageTextId;

                tbMessageText.CssClass = "text-box message-text";

                tbMessageText.Text = IsNullOrWhiteSpace(nagsRow.MessageText)
          ? Empty
          : nagsRow.MessageText;
            }
            // Display-only columns
            else
            {
                var p = new HtmlP();
                tdMessageNumber.Controls.Add(p);
                p.InnerHtml = msgNo;

                p = new HtmlP();
                tdNextMessageNumber.Controls.Add(p);
                p.InnerHtml = nagsRow.NextMessageNumber == null
          ? "&nbsp;"
          : nagsRow.NextMessageNumber.ToString();

                p = new HtmlP();
                tdMessageText.Controls.Add(p);
                p.InnerHtml = IsNullOrWhiteSpace(nagsRow.MessageText)
          ? "&nbsp;"
          : nagsRow.MessageText;
            }
        }
Beispiel #13
0
        private void BuildInsertRow(string editMode, Control htmlTable)
        {
            var trInsert = new TableRow();

            htmlTable.Controls.Add(trInsert);

            // First operation column
            var tdInsertAction1 = new TableCell();

            trInsert.Controls.Add(tdInsertAction1);
            if (editMode == "Insert")
            {
                var insertLinkButton1 = new LinkButton();
                tdInsertAction1.Controls.Add(insertLinkButton1);
                insertLinkButton1.CssClass = "op op-add";
                insertLinkButton1.Text     = "Add";
                insertLinkButton1.ID       = "Add";
                insertLinkButton1.ToolTip  = "Update the database with the new message";
                insertLinkButton1.Click   += AddButton_Click;
            }
            else
            {
                tdInsertAction1.Text = "&nbsp;";
            }

            // Second operation column
            var tdInsertAction2 = new TableCell();

            trInsert.Controls.Add(tdInsertAction2);
            LinkButton insertLinkButton2;

            if (editMode == "Insert")
            {
                insertLinkButton2 = new LinkButton();
                tdInsertAction2.Controls.Add(insertLinkButton2);
                insertLinkButton2.CssClass = "op op-cancel";
                insertLinkButton2.Text     = "Cancel";
                insertLinkButton2.ID       = "Cancel";
                insertLinkButton2.ToolTip  =
                    "Cancel creation of the new message -- no changes will be made to the database";
                insertLinkButton2.Click += CancelButton_Click;
            }
            else
            {
                insertLinkButton2 = new LinkButton();
                tdInsertAction2.Controls.Add(insertLinkButton2);
                insertLinkButton2.CssClass = "op op-insert";
                insertLinkButton2.Text     = "Insert";
                insertLinkButton2.ID       = "Insert";
                insertLinkButton2.ToolTip  = "Create a new message";
                insertLinkButton2.Click   += InsertButton_Click;
            }

            // Create data columns
            var tdInsertMessageNumber = new TableCell();

            trInsert.Controls.Add(tdInsertMessageNumber);
            tdInsertMessageNumber.CssClass = "content";

            var tdInsertNextMessageNumber = new TableCell();

            trInsert.Controls.Add(tdInsertNextMessageNumber);
            tdInsertNextMessageNumber.CssClass = "content";

            //var tdInsertMessageHeading = new TableCell();
            //trInsert.Controls.Add(tdInsertMessageHeading);
            //tdInsertMessageHeading.CssClass = "content";

            var tdInsertMessageText = new TableCell();

            trInsert.Controls.Add(tdInsertMessageText);
            tdInsertMessageText.CssClass = "content";

            // Populate data columns
            // If there is an active insertion, populate with TextBoxes
            if (editMode == "Insert")
            {
                TextBox tbInsertMessageNumber = new TextBoxWithNormalizedLineBreaks();
                tdInsertMessageNumber.Controls.Add(tbInsertMessageNumber);
                tbInsertMessageNumber.ID       = TextBoxMessageNumberId;
                tbInsertMessageNumber.CssClass = "text-box message-number";

                TextBox tbInsertNextMessageNumber = new TextBoxWithNormalizedLineBreaks();
                tdInsertNextMessageNumber.Controls.Add(tbInsertNextMessageNumber);
                tbInsertNextMessageNumber.ID       = TextBoxNextMessageNumberId;
                tbInsertNextMessageNumber.CssClass = "text-box next-message-number";

                TextBox tbInsertMessageText = new TextBoxWithNormalizedLineBreaks();
                tdInsertMessageText.Controls.Add(tbInsertMessageText);
                tbInsertMessageText.ID       = TextBoxMessageTextId;
                tbInsertMessageText.CssClass = "text-box message-text";
            }
            // Empty placeholders
            else
            {
                var p = new HtmlP();
                tdInsertMessageNumber.Controls.Add(p);
                p.InnerHtml = "&nbsp;";

                p = new HtmlP();
                tdInsertNextMessageNumber.Controls.Add(p);
                p.InnerHtml = "&nbsp;";

                //p = new HtmlP();
                //tdInsertMessageHeading.Controls.Add(p);
                //p.InnerHtml = "&nbsp;";

                p = new HtmlP();
                tdInsertMessageText.Controls.Add(p);
                p.InnerHtml = "&nbsp;";
            }
        }
        private HtmlControl ReportCandidate(DataRow candidate)
        {
            var info = new HtmlDiv().AddCssClasses("info");

            var name          = new HtmlP().AddTo(info, "name");
            var isPrimary     = Elections.IsPrimaryElection(candidate.ElectionKey());
            var isNonPartisan =
                Elections.GetNationalPartyCode(candidate.ElectionKey()) == "X";

            FormatCandidate(candidate, true, (!isPrimary || isNonPartisan) &&
                            !candidate.IsRunningMate())
            .AddTo(name);

            if (candidate.IsWinner() && !candidate.IsRunningMate())
            {
                info.AddCssClasses("winner");
                new HtmlDiv()
                .Attribute("title", "Winner")
                .AddTo(info, "winner-icon");
            }

            new HtmlImage
            {
                Src = VotePage.GetPoliticianImageUrl(candidate.PoliticianKey(), 75)
            }.AddTo(
                info, "rounded-border headshot");

            var rightSide = new HtmlDiv().AddTo(info, "right-side");

            FormatCandidatePhone(candidate)
            .AddTo(rightSide);

            FormatCandidateWebsite(candidate)
            .AddTo(rightSide);

            SocialMedia.GetAnchors(candidate)
            .AddCssClasses("social")
            .AddTo(rightSide);

            var address      = candidate.PublicAddress();
            var cityStateZip = candidate.PublicCityStateZip();

            if (!string.IsNullOrWhiteSpace(address) &&
                !string.IsNullOrWhiteSpace(cityStateZip))
            {
                var addressTag = new HtmlDiv().AddTo(rightSide, "address");
                new HtmlP {
                    InnerText = address
                }.AddTo(addressTag);
                new HtmlP {
                    InnerText = cityStateZip
                }.AddTo(addressTag);
            }

            var age = candidate.Age();

            if (!string.IsNullOrWhiteSpace(age))
            {
                var ageTag = new HtmlDiv().AddTo(rightSide, "age");
                new HtmlSpan {
                    InnerText = "Age: "
                }.AddTo(ageTag);
                new LiteralControl(age).AddTo(ageTag);
            }

            ClearBoth()
            .AddTo(info);

            return(info);
        }