protected void Page_Load(object sender, EventArgs e)
        {
            RegisterClientScript();

            if (Request.QueryString["iframe"] == "true")
            {
                form.AddCssClasses("iframe");
                this.IncludeJs("/js/jq/iframeResizer.contentWindow.min.js");
            }

            var     totalContests  = 0;
            var     ballotMeasures = 0;
            var     electionKey    = QueryElection;
            var     congress       = QueryCongress;
            var     stateSenate    = QueryStateSenate;
            var     stateHouse     = QueryStateHouse;
            var     countyCode     = QueryCounty;
            var     electionDesc   = Elections.GetElectionDesc(electionKey);
            Control report         = null;

            if (!string.IsNullOrWhiteSpace(electionKey) &&
                !string.IsNullOrWhiteSpace(congress) &&
                !string.IsNullOrWhiteSpace(stateSenate) &&
                !string.IsNullOrWhiteSpace(stateHouse) && !string.IsNullOrWhiteSpace(countyCode))
            {
                report = BallotReport2Tabbed.GetReport(electionKey, congress, stateSenate,
                                                       stateHouse, countyCode, out totalContests, out ballotMeasures);
            }

            if (totalContests != 0 || ballotMeasures != 0)
            {
                H1.InnerText = electionDesc;
                report.AddTo(ReportPlaceHolder);
                FillInDropdowns(electionKey, countyCode, congress, stateSenate, stateHouse);
            }
            else
            {
                StateCache.Populate(StateList, "<find address or select state>", string.Empty);
                var defaultList = new List <SimpleListItem>
                {
                    new SimpleListItem
                    {
                        Text  = "<find address or select state>",
                        Value = string.Empty
                    }
                };
                Utility.PopulateFromList(CountyList, defaultList);
                Utility.PopulateFromList(CongressList, defaultList);
                Utility.PopulateFromList(StateSenateList, defaultList);
                Utility.PopulateFromList(StateHouseList, defaultList);
                Utility.PopulateFromList(ElectionList, defaultList);
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var stateName = PublicMasterPage.StateName + " ";
                if (stateName == "US ")
                {
                    stateName = Empty;
                }
                Title           = Format(TitleTag, PublicMasterPage.SiteName);
                MetaDescription = Format(MetaDescriptionTag, stateName);
            }

            string selectedState = null;
            string firstEntry    = null;

            if (DomainData.IsValidStateCode) // Single state
            {
                selectedState = DomainData.FromQueryStringOrDomain;
                AddStateLinksToDiv(StateLinkEntries, selectedState, true, true);
                StateName.InnerText = StateCache.GetStateName(selectedState);
            }
            else
            {
                firstEntry = "<select state>";
                new HtmlP {
                    InnerText = "No state selected"
                }.AddTo(StateLinkEntries);
                StateName.InnerText = "<no state selected>";
            }

            StateCache.Populate(StateElectionDropDown, firstEntry, "XX", selectedState);

            GetLinkBox(PresidentLinks, "US President and Vice-President",
                       GetPresidentLinks());
            GetLinkBox(SenateLinks, "US Senate", GetSenateLinks());
            GetLinkBox(HouseLinks, "US House of Representatives", GetHouseLinks());
            GetLinkBox(GovernorLinks, "State Governors and Lieutenant Governors",
                       GetGovernorLinks());
        }
        private void FillInDropdowns(string electionKey, string countyCode,
                                     string congress, string stateSenate, string stateHouse)
        {
            var stateCode = Elections.GetStateCodeFromKey(electionKey);

            StateCache.Populate(StateList, "<select a state>", string.Empty, stateCode);
            CountyCache.Populate(CountyList, stateCode, "<select a county>", string.Empty,
                                 countyCode);
            // reduce CongressionalDistrict codes from 3 to 2 characters
            if (congress.Length == 3)
            {
                congress = congress.Substring(1);
            }
            Utility.PopulateFromList(CongressList,
                                     new List <SimpleListItem> {
                new SimpleListItem(string.Empty, "<select a congressional district>")
            }
                                     .Union(Offices.GetDistrictItems(stateCode, OfficeClass.USHouse)
                                            .Select(i =>
            {
                i.Value = i.Value.Substring(1);
                return(i);
            })), congress);
            Utility.PopulateFromList(StateSenateList,
                                     new List <SimpleListItem> {
                new SimpleListItem(string.Empty, "<select a state senate district>")
            }
                                     .Union(Offices.GetDistrictItems(stateCode, OfficeClass.StateSenate)), stateSenate);
            Utility.PopulateFromList(StateHouseList,
                                     new List <SimpleListItem> {
                new SimpleListItem(string.Empty, "<select a state house district>")
            }
                                     .Union(Offices.GetDistrictItems(stateCode, OfficeClass.StateHouse)), stateHouse);
            Utility.PopulateFromList(ElectionList,
                                     BulkEmailPage.GetPreviewElectionItems(stateCode, string.Empty, string.Empty,
                                                                           "<select an election>"),
                                     electionKey);
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var firstNameControl = new TextBoxWithNormalizedLineBreaks().AddCssClasses("email-form-first-name narrow no-zoom");

            EmailForm.AddOptionalItem(firstNameControl, true, "EmailFormFirstName", "First Name");

            var lastNameControl = new TextBoxWithNormalizedLineBreaks().AddCssClasses("email-form-last-name narrow no-zoom");

            EmailForm.AddOptionalItem(lastNameControl, true, "EmailFormLastName", "Last Name");

            var partyControl = new HtmlSelect();

            partyControl.AddCssClasses("email-form-party narrow no-zoom");
            //Parties.PopulateNationalParties(partyControl, true, null, true);
            // eliminate non-partisan
            Parties.PopulateNationalParties(partyControl, false, null, true);
            EmailForm.AddOptionalItem(partyControl, true, "EmailFormParty",
                                      "Your Preferred Political Party – the political party you would like to focus most of your efforts on",
                                      "Preferred Political Party");

            var stateControl = new HtmlSelect();

            stateControl.AddCssClasses("email-form-state narrow no-zoom");
            StateCache.Populate(stateControl, "--- Select state ---", Empty);
            EmailForm.AddOptionalItem(stateControl, true, "EmailFormState", "Your State", "State");

            var phoneControl = new TextBoxWithNormalizedLineBreaks().AddCssClasses("email-form-phone narrow no-zoom");

            EmailForm.AddOptionalItem(phoneControl, "EmailFormPhone",
                                      "Phone Number – only used if we can not reach you via email (optional)",
                                      "Phone");

            var passwordControl = new TextBoxWithNormalizedLineBreaks().AddCssClasses("email-form-password narrow no-zoom");

            EmailForm.AddOptionalItem(passwordControl, "EmailFormPassword",
                                      "Preferred Login Password – we will create and assign one for you if you have no preference (optional)",
                                      "Preferred Login Password");

            EmailForm.MessageOptional = true;
            EmailForm.Callback        = SubmitCallback;

            if (DomainData.IsValidStateCode) // Single state
            {
                Title           = $"{PublicMasterPage.SiteName} | {TitleTagSingleStateDomain.Substitute()}";
                MetaDescription = MetaDescriptionSingleStateDomain.Substitute();
            }
            else
            {
                Title           = $"{PublicMasterPage.SiteName} | {TitleTagAllStatesDomain.Substitute()}";
                MetaDescription = MetaDescriptionAllStatesDomain.Substitute();
            }

            EmailForm.ToEmailAddress = "*****@*****.**";
            EmailForm.CcEmailAddress = "*****@*****.**";

            EmailForm.SetItems(
                "I would like to volunteer for whatever is needed",
                "I would like to volunteer to scrape candidate websites",
                "I would like to volunteer to research county and local elected offices",
                "I would like to volunteer to interview and video candidates",
                "I would like to volunteer to speak to my local political parties/community outreach groups",
                "I would like to contact candidates via email");
        }