private void BindPaymentProcessor() { var listController = new ListController(); processorCombo.DataSource = listController.GetListEntryInfoItems("Processor", ""); processorCombo.DataBind(); processorCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", ""); processorCombo.Select(Entities.Host.Host.PaymentProcessor, true); processorLink.NavigateUrl = Globals.AddHTTP(processorCombo.SelectedItem.Value); txtUserId.Text = Entities.Host.Host.ProcessorUserId; txtPassword.Attributes.Add("value", Entities.Host.Host.ProcessorPassword); txtHostFee.Text = Entities.Host.Host.HostFee.ToString(); currencyCombo.DataSource = listController.GetListEntryInfoItems("Currency", ""); var currency = Entities.Host.Host.HostCurrency; if (String.IsNullOrEmpty(currency)) { currency = "USD"; } currencyCombo.DataBind(currency); txtHostSpace.Text = Entities.Host.Host.HostSpace.ToString(); txtPageQuota.Text = Entities.Host.Host.PageQuota.ToString(); txtUserQuota.Text = Entities.Host.Host.UserQuota.ToString(); txtDemoPeriod.Text = Entities.Host.Host.DemoPeriod.ToString(); chkDemoSignup.Checked = Entities.Host.Host.DemoSignup; }
override protected void OnInit(EventArgs e) { grdCountryTaxRates.ItemCreated += grdCountryTaxRates_ItemCreated; grdCountryTaxRates.ItemCommand += grdCountryTaxRates_ItemCommand; btnSaveTaxRates.Click += btnSaveTaxRates_Click; _countries = new List <ListEntryInfo>(_listController.GetListEntryInfoItems("Country")); base.OnInit(e); }
///----------------------------------------------------------------------------- /// <summary> /// Removes profanity words in the provided input string. /// </summary> /// <remarks> /// The words to search could be defined in two different places: /// 1) In an external file. (NOT IMPLEMENTED) /// 2) In System/Site lists. /// The name of the System List is "ProfanityFilter". The name of the list in each portal is composed using the following rule: /// "ProfanityFilter-" + PortalID. /// </remarks> /// <param name="inputString">The string to search the words in.</param> /// <param name="configType">The type of configuration.</param> /// <param name="configSource">The external file to search the words. Ignored when configType is ListController.</param> /// <param name="filterScope">When using ListController configType, this parameter indicates which list(s) to use.</param> /// <returns>The original text with the profanity words removed.</returns> ///----------------------------------------------------------------------------- public string Remove(string inputString, ConfigType configType, string configSource, FilterScope filterScope) { switch (configType) { case ConfigType.ListController: const RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Singleline; const string listName = "ProfanityFilter"; var listController = new ListController(); PortalSettings settings; IEnumerable <ListEntryInfo> listEntryHostInfos; IEnumerable <ListEntryInfo> listEntryPortalInfos; switch (filterScope) { case FilterScope.SystemList: listEntryHostInfos = listController.GetListEntryInfoItems(listName, "", Null.NullInteger); inputString = listEntryHostInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + Regex.Escape(removeItem.Text) + @"\b", string.Empty, options)); break; case FilterScope.SystemAndPortalList: settings = PortalController.Instance.GetCurrentPortalSettings(); listEntryHostInfos = listController.GetListEntryInfoItems(listName, "", Null.NullInteger); listEntryPortalInfos = listController.GetListEntryInfoItems(listName + "-" + settings.PortalId, "", settings.PortalId); inputString = listEntryHostInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + Regex.Escape(removeItem.Text) + @"\b", string.Empty, options)); inputString = listEntryPortalInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + Regex.Escape(removeItem.Text) + @"\b", string.Empty, options)); break; case FilterScope.PortalList: settings = PortalController.Instance.GetCurrentPortalSettings(); listEntryPortalInfos = listController.GetListEntryInfoItems(listName + "-" + settings.PortalId, "", settings.PortalId); inputString = listEntryPortalInfos.Aggregate(inputString, (current, removeItem) => Regex.Replace(current, @"\b" + Regex.Escape(removeItem.Text) + @"\b", string.Empty, options)); break; } break; case ConfigType.ExternalFile: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException("configType"); } return(inputString); }
/// <summary> /// Calculate tax according the country/region of the deliveryAddress. /// </summary> /// <param name="portalID">ID of the portal</param> /// <param name="cartItems">List of ICartItemInfo that need to have taxes calculated on.</param> /// <param name="shippingInfo">ShippingInfo in the case that taxes need to be applied to shipping</param> /// <param name="billingAddress">The address that the taxes should be applied for.</param> /// <returns>ITaxInfo with the total amount of tax due for the cart items shipping cost.</returns> public ITaxInfo CalculateSalesTax <T>(int portalID, IEnumerable <T> cartItems, IShippingInfo shippingInfo, IAddressInfo billingAddress) where T : ICartItemInfo { TaxInfo taxInfo = GetTaxRates(portalID); if (taxInfo != null && taxInfo.ShowTax) { decimal taxRate = taxInfo.DefaultTaxRate / 100; if (billingAddress != null && taxInfo.CountryTaxes != null) { ListController listController = new ListController(); List <ListEntryInfo> countries = new List <ListEntryInfo>(listController.GetListEntryInfoItems("Country")); string countryCode = GetEntryValue(billingAddress.CountryCode, countries); string regionCode = billingAddress.RegionCode; if (!string.IsNullOrEmpty(regionCode)) { List <ListEntryInfo> regions = new List <ListEntryInfo>(listController.GetListEntryInfoItems("Region", "Country." + countryCode)); regionCode = GetEntryValue(regionCode, regions); } taxRate = GetCountryRegionTaxRate(countryCode, regionCode, billingAddress.PostalCode, taxInfo.CountryTaxes, taxInfo.DefaultTaxRate); } // Compute Shipping Tax if needed taxInfo.ShippingTax = shippingInfo.ApplyTaxRate ? shippingInfo.Cost * taxRate : 0M; // Compute Sales Tax decimal cartTotal = 0M; foreach (T itemInfo in cartItems) { cartTotal += (itemInfo.SubTotal - itemInfo.Discount) * taxRate; } taxInfo.SalesTax = cartTotal + taxInfo.ShippingTax; } else { if (taxInfo == null) { taxInfo = new TaxInfo(); } taxInfo.ShowTax = false; taxInfo.DefaultTaxRate = 0M; taxInfo.SalesTax = 0M; taxInfo.ShippingTax = 0M; } return(taxInfo); }
private static string GetISOCountryCode(string country) { string isoCode = string.Empty; if (country == "United Kingdom") { isoCode = "GB"; } else { ListController listController = new ListController(); IEnumerable <ListEntryInfo> listEntries = listController.GetListEntryInfoItems("Country"); foreach (ListEntryInfo itemInfo in listEntries) { if (itemInfo.Text == country) { isoCode = itemInfo.Value; break; } } } return(isoCode); }
private void LoadCountryList() { ListController listController = new ListController(); List<ListEntryInfo> listEntries = new List<ListEntryInfo>(listController.GetListEntryInfoItems("Country")); if (listEntries.Count > 0) { if (_settings.RestrictToCountries) { string authorizedCountries = _settings.AuthorizedCountries; if (!string.IsNullOrEmpty(authorizedCountries)) { List<ListEntryInfo> restricted = new List<ListEntryInfo>(); foreach (string authorizedCountry in authorizedCountries.Split(',')) { string key = "Country:" + authorizedCountry; restricted.Add(listEntries.Find(e => e.Key == key)); } cboCountry.DataSource = restricted; cboCountry.DataBind(); } } else { cboCountry.DataSource = listEntries; cboCountry.DataBind(); } cboCountry.Items.Insert(0, new ListItem("< " + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + " >", "")); cboCountry.SelectedIndex = 0; } else rowCountry.Visible = false; }
private void ParseRegionLoadSetting() { if (string.IsNullOrEmpty(GetSetting(FeatureController.KEY_REGION)) == false) { LoadRegions(cboCountry.SelectedValue); var ctlList = new ListController(); var value = GetSetting(FeatureController.KEY_REGION); var listItem = from i in ctlList.GetListEntryInfoItems("Region", string.Concat("Country.", GetSetting(FeatureController.KEY_COUNTRY)), PortalId) select i; if (listItem.Any()) { cboRegion.Items.FindByValue(value).Selected = true; ToggleRegion(RegionState.DropDownList); } else { txtRegion.Text = value; ToggleRegion(RegionState.TextBox); } } else { // default state ToggleRegion(RegionState.TextBox); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/15/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); cmdDisplay.Click += OnDisplayClick; try { //If this is the first visit to the page, bind the role data to the datalist if (Page.IsPostBack == false) { var strSiteLogStorage = "D"; if (!string.IsNullOrEmpty(Host.SiteLogStorage)) { strSiteLogStorage = Host.SiteLogStorage; } if (strSiteLogStorage == "F") { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FileSystem", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); cmdDisplay.Visible = false; } else { switch (PortalSettings.SiteLogHistory) { case -1: //unlimited break; case 0: UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("LogDisabled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); break; default: UI.Skins.Skin.AddModuleMessage(this, string.Format(Localization.GetString("LogHistory", LocalResourceFile), PortalSettings.SiteLogHistory), ModuleMessage.ModuleMessageType.YellowWarning); break; } cmdDisplay.Visible = true; } var ctlList = new ListController(); var colSiteLogReports = ctlList.GetListEntryInfoItems("Site Log Reports"); cboReportType.DataSource = colSiteLogReports; cboReportType.DataBind(); cboReportType.SelectedIndex = 0; diStartDate.SelectedDate = DefaultBeginDate; diEndDate.SelectedDate = DefaultEndDate; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private void LoadCountries() { var ctlList = new ListController(); cboCountry.DataSource = ctlList.GetListEntryInfoItems("Country", string.Empty, PortalId); cboCountry.DataTextField = "Text"; cboCountry.DataValueField = "Value"; cboCountry.DataBind(); cboCountry.Items.Insert(0, new ListItem("---")); }
public bool FoundBannedPassword(string inputString) { const string listName = "BannedPasswords"; var listController = new ListController(); PortalSettings settings = PortalController.GetCurrentPortalSettings(); IEnumerable <ListEntryInfo> listEntryHostInfos = listController.GetListEntryInfoItems(listName, "", Null.NullInteger); IEnumerable <ListEntryInfo> listEntryPortalInfos = listController.GetListEntryInfoItems(listName + "-" + settings.PortalId, "", settings.PortalId); IEnumerable <ListEntryInfo> query2 = listEntryHostInfos.Where(test => test.Text == inputString); IEnumerable <ListEntryInfo> query3 = listEntryPortalInfos.Where(test => test.Text == inputString); if (query2.Any() || query3.Any()) { return(true); } return(false); }
public ActionResult GetCountries() { var controller = new ListController(); var list = controller.GetListEntryInfoItems("Country"); var tempList = list.Select(x => new { x.Text, x.Value }).ToList(); var noneText = DotNetNuke.Services.Localization.Localization.GetString( "None_Specified", DotNetNuke.Services.Localization.Localization.SharedResourceFile); tempList.Insert(0, new { Text = "<" + noneText + ">", Value = "" }); return(Json(tempList)); }
private string ParseRegionSaveSetting() { var ctlList = new ListController(); var value = string.Empty; var listItem = from i in ctlList.GetListEntryInfoItems("Region", string.Concat("Country.", cboCountry.SelectedValue), PortalId) select i; value = listItem.Any() ? cboRegion.SelectedValue : txtRegion.Text.Trim(); return(value); }
private bool ApplyFreeShipping(IEnumerable <ItemInfo> cartItems, string shippingCountry) { bool apply = false; if (StoreSettings.AllowFreeShipping) { decimal totalCart = 0; foreach (ItemInfo cartItem in cartItems) { totalCart += cartItem.SubTotal; } apply = totalCart >= StoreSettings.MinOrderAmount; if (apply && StoreSettings.RestrictToCountries) { ListController listController = new ListController(); List <ListEntryInfo> listEntries = new List <ListEntryInfo>(listController.GetListEntryInfoItems("Country")); string countryCode = string.Empty; string authorizedCountries = StoreSettings.AuthorizedCountries; apply = false; if (!string.IsNullOrEmpty(shippingCountry) && listEntries.Count > 0) { // Search for country name foreach (ListEntryInfo country in listEntries) { if (country.Text.Equals(shippingCountry, StringComparison.CurrentCultureIgnoreCase)) { countryCode = country.Value; break; } } } if (!string.IsNullOrEmpty(authorizedCountries) && !string.IsNullOrEmpty(countryCode)) { foreach (string country in authorizedCountries.Split(',')) { apply = country.Equals(countryCode, StringComparison.CurrentCultureIgnoreCase); if (apply) { break; } } } } } return(apply); }
/// <summary> /// 推送州/区域的数据 /// </summary> public void PushCountryRegion() { Dictionary <String, Object> jsonRegions = new Dictionary <string, Object>(); String CountryName = WebHelper.GetStringParam(Request, "Country", ""); if (!String.IsNullOrEmpty(CountryName)) { ListController listController = new ListController(); //ListEntryInfo thisCountry = new ListEntryInfo(); //var Countrys= listController.GetListEntryInfoItems("Country"); //foreach (ListEntryInfo Country in Countrys) //{ // if (!String.IsNullOrEmpty(Country.Value) && CountryName == Country.Value) // { // thisCountry = Country; // break; // } //} //if (thisCountry != null && thisCountry.EntryID > 0) //{ //var entryCollection = listController.GetListEntryInfoItems("Region", String.Format("Country.{0}", thisCountry.Value)); var entryCollection = listController.GetListEntryInfoItems("Region", String.Format("Country.{0}", CountryName)); foreach (ListEntryInfo Country in entryCollection) { if (!String.IsNullOrEmpty(Country.Text)) { Dictionary <String, Object> jsonRegion = new Dictionary <string, Object>(); jsonRegion.Add("Text", Country.Text); jsonRegions.Add(Country.EntryID.ToString(), jsonRegion); } } //} } JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); Response.Clear(); Response.Write(jsSerializer.Serialize(jsonRegions)); Response.End(); }
private void BindPaymentProcessor(PortalInfo portal) { var listController = new ListController(); currencyCombo.DataSource = listController.GetListEntryInfoItems("Currency", ""); var currency = portal.Currency; if (String.IsNullOrEmpty(currency)) { currency = "USD"; } currencyCombo.DataBind(currency); processorCombo.DataSource = listController.GetListEntryInfoItems("Processor", ""); processorCombo.DataBind(); processorCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", ""); processorCombo.Select(Host.PaymentProcessor, true); processorLink.NavigateUrl = Globals.AddHTTP(processorCombo.SelectedItem.Value); txtUserId.Text = portal.ProcessorUserId; txtPassword.Attributes.Add("value", portal.ProcessorPassword); // use sandbox? bool bolPayPalSandbox = Boolean.Parse(PortalController.GetPortalSetting("paypalsandbox", portal.PortalID, "false")); chkPayPalSandboxEnabled.Checked = bolPayPalSandbox; // return url after payment or on cancel string strPayPalReturnURL = PortalController.GetPortalSetting("paypalsubscriptionreturn", portal.PortalID, Null.NullString); txtPayPalReturnURL.Text = strPayPalReturnURL; string strPayPalCancelURL = PortalController.GetPortalSetting("paypalsubscriptioncancelreturn", portal.PortalID, Null.NullString); txtPayPalCancelURL.Text = strPayPalCancelURL; }
public static string GetControlType(int DataTypeID) { string _ControlType = string.Empty; ListController listController = new ListController(); var ListDataTypeInfo = listController.GetListEntryInfoItems("DataType", "", PortalSettings.Current.PortalId).ToList(); foreach (var dInfo in ListDataTypeInfo) { if (dInfo.EntryID == DataTypeID) { _ControlType = dInfo.Value; } } return(_ControlType); }
private static bool IsExistsDataType(int dataType) { bool IsExistsDataType = false; ListController listController = new ListController(); foreach (var d in listController.GetListEntryInfoItems("DataType").Where(x => !ExcludeControls.Contains(x.Value)).ToList()) { if (d.EntryID == dataType) { IsExistsDataType = true; break; } } return(IsExistsDataType); }
private void BindCountry() { var ctlEntry = new ListController(); var entryCollection = ctlEntry.GetListEntryInfoItems("Country"); cboCountry.DataSource = entryCollection; cboCountry.DataBind(); cboCountry.Items.Insert( 0, new ListItem("<" + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + ">", "")); if (!Page.IsPostBack) { cboCountry.SelectedIndex = 0; } }
private void BindRegion() { var ctlEntry = new ListController(); var countryCode = Convert.ToString(cboCountry.SelectedItem.Value); var listKey = "Country." + countryCode; // listKey in format "Country.US:Region" var entryCollection = ctlEntry.GetListEntryInfoItems("Region", listKey); if (entryCollection.Any()) { txtRegion.Visible = false; cboRegion.Visible = true; cboRegion.Items.Clear(); cboRegion.DataSource = entryCollection; cboRegion.DataBind(); cboRegion.Items.Insert( 0, new ListItem( "<" + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + ">", "")); if (countryCode.ToLower() == "us") { lblRegionCap.Text = Localization.GetString("plState.Text", LocalResourceFile); lblRegionCap.HelpText = Localization.GetString("plState.Help", LocalResourceFile); lblPostalCodeCap.Text = Localization.GetString("plZipCode.Text", LocalResourceFile); lblPostalCodeCap.HelpText = Localization.GetString("plZipCode.Help", LocalResourceFile); } else { lblRegionCap.Text = Localization.GetString("plRegion.Text", LocalResourceFile); lblRegionCap.HelpText = Localization.GetString("plRegion.Help", LocalResourceFile); lblPostalCodeCap.Text = Localization.GetString("plPostalCode.Text", LocalResourceFile); lblPostalCodeCap.HelpText = Localization.GetString("plPostalCode.Help", LocalResourceFile); } } else { txtRegion.Visible = true; cboRegion.Visible = false; lblRegionCap.Text = Localization.GetString("plRegion.Text", LocalResourceFile); lblRegionCap.HelpText = Localization.GetString("plRegion.Help", LocalResourceFile); lblPostalCodeCap.Text = Localization.GetString("plPostalCode.Text", LocalResourceFile); lblPostalCodeCap.HelpText = Localization.GetString("plPostalCode.Help", LocalResourceFile); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); // set URLs for cancel links linkCancel.NavigateUrl = UrlHelper.GetCancelUrl(UrlUtils.InPopUp()); linkClose.NavigateUrl = Globals.NavigateURL(); cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + LocalizeString("Delete.Text") + "');"); buttonDeleteWithResource.Attributes.Add("onClick", "javascript:return confirm('" + LocalizeString("DeleteWithResource.Text") + "');"); cmdUpdateOverride.Text = LocalizeString("Proceed.Text"); cmdUpdateOverride.ToolTip = LocalizeString("Proceed.ToolTip"); linkAddMore.Text = LocalizeString("AddMoreDocuments.Text"); linkAddMore.ToolTip = LocalizeString("AddMoreDocuments.Text"); // Configure categories entry as a list or textbox, based on user settings if (Settings.UseCategoriesList) { // Configure category entry as a list lstCategory.Visible = true; txtCategory.Visible = false; // Populate categories list var listController = new ListController(); lstCategory.DataSource = listController.GetListEntryInfoItems(Settings.CategoriesListName); lstCategory.DataTextField = "Text"; lstCategory.DataValueField = "Value"; lstCategory.DataBind(); lstCategory.Items.Insert(0, new ListItem(Localization.GetString("None_Specified"), Null.NullInteger.ToString())); } else { // Configure category entry as a free-text entry lstCategory.Visible = false; txtCategory.Visible = true; } BindUrlHistory(); }
private static string GetUSPostalRegionCode(string ISOCountry, string region) { string regionCode = string.Empty; ListController listController = new ListController(); string listKey = "Country." + ISOCountry; IEnumerable <ListEntryInfo> listEntries = listController.GetListEntryInfoItems("Region", listKey); foreach (ListEntryInfo itemInfo in listEntries) { if (itemInfo.Text == region) { regionCode = itemInfo.Value; break; } } return(regionCode); }
public static ActionResult GetProfileProperty(int?propertyId, int?portalId) { ActionResult actionResult = new ActionResult(); try { int pid = portalId ?? PortalSettings.Current.PortalId; if (!PortalSettings.Current.UserInfo.IsSuperUser && PortalSettings.Current.PortalId != pid) { actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage); } if (actionResult.IsSuccess) { ProfilePropertyDefinition profileProperty = ProfileController.GetPropertyDefinition(propertyId ?? -1, pid); ListController listController = new ListController(); System.Collections.Generic.IEnumerable <System.Web.UI.WebControls.ListItem> cultureList = DNNLocalization.Localization.LoadCultureInListItems(GetCultureDropDownType(pid), Thread.CurrentThread.CurrentUICulture.Name, "", false); var response = new { Success = true, ProfileProperty = MapProfileProperty(profileProperty), UserVisibilityOptions = GetVisibilityOptions(), DataTypeOptions = listController.GetListEntryInfoItems("DataType").Where(x => !ExcludeControls.Contains(x.Value)).Select(t => new { t.EntryID, Value = DNNLocalization.Localization.GetString(Components.Constants.Prefix + Regex.Replace(t.Value.ToString(), "[ ().-]+", ""), Components.Constants.LocalResourcesFile), }).OrderBy(t => t.Value).ToList(), LanguageOptions = cultureList.Select(c => new { c.Text, c.Value }) }; actionResult.Data = response; } } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }
public static Dictionary <String, String> GetCountryCodeList(int portalId = -1) { var rtnDic = new Dictionary <String, String>(); if (portalId == -1 && PortalSettings.Current != null) { portalId = PortalSettings.Current.PortalId; } if (portalId != -1) { var objLCtrl = new ListController(); var l = objLCtrl.GetListEntryInfoItems("Country").ToList(); foreach (var i in l) { rtnDic.Add(i.Value, i.Text); } } return(rtnDic); }
public void GetStates() { try { var ctlList = new ListController(); var leic = ctlList.GetListEntryInfoItems("Region", "Country.US"); ddlState.DataTextField = "Text"; ddlState.DataValueField = "Value"; ddlState.DataSource = leic; ddlState.DataBind(); ddlState.Items.Insert(0, new ListItem("Select State", "-1")); ddlState.SelectedValue = "MA"; } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
private void FillAuthorizedCountries(string authorizedCountries) { ListController listController = new ListController(); IEnumerable <ListEntryInfo> listEntries = listController.GetListEntryInfoItems("Country"); lbAuthorizedCountries.DataSource = listEntries; lbAuthorizedCountries.DataBind(); if (!string.IsNullOrEmpty(authorizedCountries)) { foreach (string authorizedCountry in authorizedCountries.Split(',')) { ListItem item = lbAuthorizedCountries.Items.FindByValue(authorizedCountry); if (item != null) { item.Selected = true; } } } }
/// <summary> /// Select a list in dropdownlist /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectListIndexChanged(object sender, EventArgs e) { var ctlLists = new ListController(); if (!string.IsNullOrEmpty(ddlSelectList.SelectedValue)) { ListInfo selList = GetList(ddlSelectList.SelectedItem.Value, false); { ddlSelectParent.Enabled = true; ddlSelectParent.DataSource = ctlLists.GetListEntryInfoItems(selList.Name, selList.ParentKey); ddlSelectParent.DataTextField = "DisplayName"; ddlSelectParent.DataValueField = "EntryID"; ddlSelectParent.DataBind(); } } else { ddlSelectParent.Enabled = false; ddlSelectParent.Items.Clear(); } }
private void LoadRegions(string CountryId) { var ctlList = new ListController(); IEnumerable <ListEntryInfo> regions = null; regions = ctlList.GetListEntryInfoItems("Region", string.Concat("Country.", CountryId), PortalId); if (regions != null && regions.Any()) { cboRegion.DataSource = regions; cboRegion.DataTextField = "Text"; cboRegion.DataValueField = "Value"; cboRegion.DataBind(); cboRegion.Items.Insert(0, new ListItem("---")); ToggleRegion(RegionState.DropDownList); } else { ToggleRegion(RegionState.TextBox); } }
void OnItemChanged(object sender, PropertyEditorEventArgs e) { var regionContainer = ControlUtilities.FindControl <Control>(Parent, "Region", true); if (regionContainer != null) { var regionControl = ControlUtilities.FindFirstDescendent <DNNRegionEditControl>(regionContainer); if (regionControl != null) { var listController = new ListController(); var countries = listController.GetListEntryInfoItems("Country"); foreach (var checkCountry in countries) { if (checkCountry.EntryID.ToString() == e.StringValue) { var attributes = new object[1]; attributes[0] = new ListAttribute("Region", "Country." + checkCountry.Value, ListBoundField.Id, ListBoundField.Text); regionControl.CustomAttributes = attributes; break; } } } } }
public static ActionResult GetListInfo(string listName, int?portalId) { ActionResult actionResult = new ActionResult(); try { int pid = portalId ?? PortalSettings.Current.PortalId; if (!PortalSettings.Current.UserInfo.IsSuperUser && PortalSettings.Current.PortalId != pid) { actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage); } if (actionResult.IsSuccess) { ListController listController = new ListController(); System.Collections.Generic.IEnumerable <ListEntryInfo> entries = listController.GetListEntryInfoItems(listName, "", pid); var response = new { Success = true, listController.GetListInfo(listName, "", pid)?.EnableSortOrder, Entries = entries.Select(t => new { t.EntryID, t.Text, t.Value, t.SortOrder }).OrderBy(x => x.SortOrder) }; actionResult.Data = response; } } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }
/// ----------------------------------------------------------------------------- /// <summary> /// CreateEditor creates the control collection. /// </summary> /// <history> /// [cnurse] 05/08/2006 created /// </history> /// ----------------------------------------------------------------------------- protected override void CreateEditor() { CategoryDataField = "PropertyCategory"; EditorDataField = "DataType"; NameDataField = "PropertyName"; RequiredDataField = "Required"; ValidationExpressionDataField = "ValidationExpression"; ValueDataField = "PropertyValue"; VisibleDataField = "Visible"; VisibilityDataField = "ProfileVisibility"; LengthDataField = "Length"; base.CreateEditor(); foreach (FieldEditorControl editor in Fields) { //Check whether Field is readonly string fieldName = editor.Editor.Name; ProfilePropertyDefinitionCollection definitions = editor.DataSource as ProfilePropertyDefinitionCollection; ProfilePropertyDefinition definition = definitions[fieldName]; if (definition != null && definition.ReadOnly && (editor.Editor.EditMode == PropertyEditorMode.Edit)) { PortalSettings ps = PortalController.GetCurrentPortalSettings(); if (!PortalSecurity.IsInRole(ps.AdministratorRoleName)) { editor.Editor.EditMode = PropertyEditorMode.View; } } //We need to wire up the RegionControl to the CountryControl if (editor.Editor is DNNRegionEditControl) { ListEntryInfo country = null; foreach (FieldEditorControl checkEditor in Fields) { if (checkEditor.Editor is DNNCountryEditControl) { var countryEdit = (DNNCountryEditControl)checkEditor.Editor; var objListController = new ListController(); var countries = objListController.GetListEntryInfoItems("Country"); foreach (ListEntryInfo checkCountry in countries) { if (checkCountry.Text == Convert.ToString(countryEdit.Value)) { country = checkCountry; break; } } } } //Create a ListAttribute for the Region string countryKey; if (country != null) { countryKey = "Country." + country.Value; } else { countryKey = "Country.Unknown"; } var attributes = new object[1]; attributes[0] = new ListAttribute("Region", countryKey, ListBoundField.Text, ListBoundField.Text); editor.Editor.CustomAttributes = attributes; } } }