public void ProcessRequest(HttpContext context) { HttpResponse response = context.Response; HttpRequest request = context.Request; response.ContentType = "text/plain"; string action = request.Params["action"]; bool? emptyFirstOption = WA.Parser.ToBool(request.Params["emptyFirstOption"]); switch (action) { case "getRegions": string countryCode = request.Params["country"]; List <ListItem> items = DnnHelper.GetRegionListItems(countryCode); StringBuilder html = new StringBuilder(); if (emptyFirstOption.GetValueOrDefault(false)) { html.Append(@"<option value=""""></option>"); } items.ForEach(item => html.AppendFormat(@"<option value=""{0}"">{1}</option>{2}", item.Value, item.Text, Environment.NewLine)); response.Write(html.ToString()); break; } response.Flush(); }
private void PopulateForm() { AddressInfo address = checkoutOrderInfo.BillingAddress; if (address.NameFieldsAreEmpty && UserId > 0) { address.FirstName = UserInfo.FirstName; address.LastName = UserInfo.LastName; address.Email = UserInfo.Email; } if (address.AddressFieldsAreEmpty && UserId > 0) { address.Telephone = UserInfo.Profile.Telephone; address.Address1 = UserInfo.Profile.Street; address.Address2 = UserInfo.Profile.Unit; address.City = UserInfo.Profile.City; address.Region = UserInfo.Profile.Region; // DNN seems to use full region name instead of abbreviation address.PostalCode = UserInfo.Profile.PostalCode; address.Country = UserInfo.Profile.Country; // DNN seems to use full country name here // try to look up the Country Code based on the Country Name List <ListItem> countryListItems = DnnHelper.GetCountryListItems(); ListItem countryItem = countryListItems.Find(c => c.Text == UserInfo.Profile.Country); if (countryItem != null) { address.Country = countryItem.Value; } // try to look up the Region Code based on the Region Name List <ListItem> regionListItems = DnnHelper.GetRegionListItems(address.Country); ListItem regionItem = regionListItems.Find(r => r.Text == UserInfo.Profile.Region); if (regionItem != null) { address.Region = regionItem.Value; } } //--- Set a default country string defaultCountry = StoreContext.CurrentStore.GetSetting(StoreSettingNames.DefaultCountryCode); if (string.IsNullOrEmpty(address.Country) && !string.IsNullOrEmpty(defaultCountry)) { address.Country = defaultCountry; } chkCopyBillingAddress.Checked = checkoutOrderInfo.ShipToBillingAddress.GetValueOrDefault(false); chkCopyBillingAddress.Visible = !checkoutOrderInfo.HasOnlyDownloadableProducts; lblCopyBilling.Visible = chkCopyBillingAddress.Visible; //--- Set the fields on the form billingAddressForm.SetAddressInfo(address); }
public void SetAddressInfo(AddressInfo addressInfo) { this.addressInfo = addressInfo; ddlCountry.TrySetSelectedValue(addressInfo.Country); if (!string.IsNullOrEmpty(ddlCountry.SelectedValue)) { // try to fill the regions drop-down using the country code SetRegionListItems(DnnHelper.GetRegionListItems(ddlCountry.SelectedValue), addressInfo.Region); } //ddlRegion.TrySetSelectedValue(addressInfo.Region); //txtRegion.Text = addressInfo.Region; //if (!string.IsNullOrEmpty(addressInfo.Region) && string.IsNullOrEmpty(ddlRegion.SelectedValue)) //{ // txtRegion.Style.Clear(); // ddlRegion.Style.Clear(); // ddlRegion.Style.Add("display", "none"); //} }