Esempio n. 1
0
        // internal static void BindListInternal(DropDownList comboBox, object value, IEnumerable listSource, string textField, string valueField)
        internal static void BindListInternal(DnnComboBox comboBox, object value, IEnumerable listSource, string textField, string valueField)
        {
            if (comboBox != null)
            {
                string selectedValue = !comboBox.Page.IsPostBack ? Convert.ToString(value) : comboBox.SelectedValue;

                if (listSource is Dictionary <string, string> )
                {
                    var items = listSource as Dictionary <string, string>;
                    foreach (var item in items)
                    {
                        // comboBox.Items.Add(new ListItem(item.Key, item.Value));
                        comboBox.AddItem(item.Key, item.Value);
                    }
                }
                else
                {
                    comboBox.DataTextField  = textField;
                    comboBox.DataValueField = valueField;
                    comboBox.DataSource     = listSource;

                    comboBox.DataBind();
                }

                // Reset SelectedValue
                // comboBox.Select(selectedValue);
                var selectedItem = comboBox.FindItemByValue(selectedValue);
                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }
        }
        public static string Update (DnnComboBox comboWorkingHours, string workingHours, bool addToVocabulary)
        {
            workingHours = workingHours.Trim ();
            var workingHoursNonEmpty = !string.IsNullOrWhiteSpace (workingHours);

            if (comboWorkingHours.SelectedIndex <= 0 || workingHoursNonEmpty)
            {
                // REVIEW: Shouldn't we try to add term after updating main item?
                if (addToVocabulary && workingHoursNonEmpty)
                {
                    // try add new term to University_WorkingHours vocabulary
                    var vocCtrl = new VocabularyController ();
                    var voc = vocCtrl.GetVocabularies ().SingleOrDefault (v => v.Name == "University_WorkingHours");
                    if (voc != null)
                    {
                        var termCtrl = new TermController ();
                        termCtrl.AddTerm (new Term (workingHours, "", voc.VocabularyId)); 
                        vocCtrl.ClearVocabularyCache ();
                    }
                }

                return workingHours;
            }

            // else: get working hours from a combo
            return comboWorkingHours.SelectedItem.Text;
        }
 public static void Load (DnnComboBox comboWorkingHours, TextBox textWorkingHours, string workingHours)
 {
     // search for working hours text in a combo
     comboWorkingHours.Select (workingHours, true);
     if (comboWorkingHours.SelectedIndex <= 0)
         textWorkingHours.Text = workingHours;
 }
        //internal static void BindListInternal(DropDownList comboBox, object value, IEnumerable listSource, string textField, string valueField)
        internal static void BindListInternal(DnnComboBox comboBox, object value, IEnumerable listSource, string textField, string valueField)
        {
            if (comboBox != null)
            {
                string selectedValue = !comboBox.Page.IsPostBack ? Convert.ToString(value) : comboBox.SelectedValue;

                if (listSource is Dictionary<string, string>)
                {
                    var items = listSource as Dictionary<string, string>;
                    foreach (var item in items)
                    {
                        //comboBox.Items.Add(new ListItem(item.Key, item.Value));
                        comboBox.AddItem(item.Key, item.Value);
                    }
                }
                else
                {
                    comboBox.DataTextField = textField;
                    comboBox.DataValueField = valueField;
                    comboBox.DataSource = listSource;

                    comboBox.DataBind();
                }

                //Reset SelectedValue
                //comboBox.Select(selectedValue);
                var selectedItem = comboBox.FindItemByValue(selectedValue);
                if (selectedItem != null)
                    selectedItem.Selected = true;                
            }
        }
Esempio n. 5
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     this._moduleCombo = new DnnComboBox();
     this._moduleCombo.DataValueField = "key";
     this._moduleCombo.DataTextField  = "value";
     this.Controls.Add(this._moduleCombo);
 }
 public static void Init (PortalModuleBase module, DnnComboBox comboWorkingHours)
 {
     // fill working hours terms
     var termCtrl = new TermController ();
     var workingHours = termCtrl.GetTermsByVocabulary ("University_WorkingHours").ToList ();
     workingHours.Insert (0, new Term (Localization.GetString ("NotSelected.Text", module.LocalResourceFile)));
     comboWorkingHours.DataSource = workingHours;
     comboWorkingHours.DataBind ();
 }
Esempio n. 7
0
        protected override WebControl CreateControlInternal(Control container)
        {
            //ComboBox = new DropDownList { ID = ID + "_ComboBox" };
            ComboBox = new DnnComboBox { ID = ID + "_ComboBox" };
            ComboBox.SelectedIndexChanged += IndexChanged;
            container.Controls.Add(ComboBox);

            if (ListSource != null)
            {
                BindList();
            }

            return ComboBox;
        }
Esempio n. 8
0
        protected override WebControl CreateControlInternal(Control container)
        {
            var panel = new Panel();

            container.Controls.Add(panel);

            var skinLabel = new Label {
                Text = LocalizeString("Skin")
            };

            skinLabel.CssClass += "dnnFormSkinLabel";
            panel.Controls.Add(skinLabel);

            //_skinCombo = new DropDownList { ID = ID + "_SkinComboBox" };
            _skinCombo = new DnnComboBox {
                ID = ID + "_SkinComboBox"
            };
            _skinCombo.CssClass             += "dnnFormSkinInput";
            _skinCombo.SelectedIndexChanged += SkinIndexChanged;
            panel.Controls.Add(_skinCombo);

            DnnFormComboBoxItem.BindListInternal(_skinCombo, _skinValue, GetSkins(SkinController.RootSkin), "Key", "Value");

            var containerLabel = new Label {
                Text = LocalizeString("Container")
            };

            containerLabel.CssClass += "dnnFormSkinLabel";
            panel.Controls.Add(containerLabel);

            //_containerCombo = new DropDownList { ID = ID + "_ContainerComboBox" };
            _containerCombo = new DnnComboBox {
                ID = ID + "_ContainerComboBox"
            };
            _containerCombo.CssClass             += "dnnFormSkinInput";
            _containerCombo.SelectedIndexChanged += ContainerIndexChanged;
            panel.Controls.Add(_containerCombo);

            DnnFormComboBoxItem.BindListInternal(_containerCombo, _containerValue, GetSkins(SkinController.RootContainer), "Key", "Value");

            return(panel);
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this._nativeCombo = new DnnComboBox();
            this._nativeCombo.DataValueField        = "Name";
            this._nativeCombo.DataTextField         = "NativeName";
            this._nativeCombo.SelectedIndexChanged += this.ItemChangedInternal;
            this.Controls.Add(this._nativeCombo);

            this._englishCombo = new DnnComboBox();
            this._englishCombo.DataValueField        = "Name";
            this._englishCombo.DataTextField         = "EnglishName";
            this._englishCombo.SelectedIndexChanged += this.ItemChangedInternal;
            this.Controls.Add(this._englishCombo);

            this._modeRadioButtonList = new RadioButtonList();
            this._modeRadioButtonList.AutoPostBack    = true;
            this._modeRadioButtonList.RepeatDirection = RepeatDirection.Horizontal;
            this._modeRadioButtonList.Items.Add(new ListItem(Localization.GetString("NativeName", Localization.GlobalResourceFile), "NATIVE"));
            this._modeRadioButtonList.Items.Add(new ListItem(Localization.GetString("EnglishName", Localization.GlobalResourceFile), "ENGLISH"));
            this._modeRadioButtonList.SelectedIndexChanged += this.ModeChangedInternal;
            this.Controls.Add(this._modeRadioButtonList);
        }
Esempio n. 10
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     _moduleCombo = new DnnComboBox();
     _moduleCombo.DataValueField = "key";
     _moduleCombo.DataTextField = "value";
     Controls.Add(_moduleCombo);
 }
Esempio n. 11
0
        protected override WebControl CreateControlInternal(Control container)
        {
            var panel = new Panel();

            container.Controls.Add(panel);

            var skinLabel = new Label { Text = LocalizeString("Skin") };
            skinLabel.CssClass += "dnnFormSkinLabel";
            panel.Controls.Add(skinLabel);

            //_skinCombo = new DropDownList { ID = ID + "_SkinComboBox" };
            _skinCombo = new DnnComboBox { ID = ID + "_SkinComboBox" };
            _skinCombo.CssClass += "dnnFormSkinInput"; 
            _skinCombo.SelectedIndexChanged += SkinIndexChanged;
            panel.Controls.Add(_skinCombo);

            DnnFormComboBoxItem.BindListInternal(_skinCombo, _skinValue, GetSkins(SkinController.RootSkin), "Key", "Value");

            var containerLabel = new Label { Text = LocalizeString("Container") };
            containerLabel.CssClass += "dnnFormSkinLabel";
            panel.Controls.Add(containerLabel);

            //_containerCombo = new DropDownList { ID = ID + "_ContainerComboBox" };
            _containerCombo = new DnnComboBox { ID = ID + "_ContainerComboBox" };
            _containerCombo.CssClass += "dnnFormSkinInput";
            _containerCombo.SelectedIndexChanged += ContainerIndexChanged;
            panel.Controls.Add(_containerCombo);

            DnnFormComboBoxItem.BindListInternal(_containerCombo, _containerValue, GetSkins(SkinController.RootContainer), "Key", "Value");

            return panel;
        }
Esempio n. 12
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _nativeCombo = new DnnComboBox();
            _nativeCombo.DataValueField = "Name";
            _nativeCombo.DataTextField = "NativeName";
            _nativeCombo.SelectedIndexChanged += ItemChangedInternal;
            Controls.Add(_nativeCombo);

            _englishCombo = new DnnComboBox();
            _englishCombo.DataValueField = "Name";
            _englishCombo.DataTextField = "EnglishName";
            _englishCombo.SelectedIndexChanged += ItemChangedInternal;
            Controls.Add(_englishCombo);

            _modeRadioButtonList = new RadioButtonList();
            _modeRadioButtonList.AutoPostBack = true;
            _modeRadioButtonList.RepeatDirection = RepeatDirection.Horizontal;
            _modeRadioButtonList.Items.Add(new ListItem(Localization.GetString("NativeName", Localization.GlobalResourceFile), "NATIVE"));
            _modeRadioButtonList.Items.Add(new ListItem(Localization.GetString("EnglishName", Localization.GlobalResourceFile), "ENGLISH"));
            _modeRadioButtonList.SelectedIndexChanged += ModeChangedInternal;
            Controls.Add(_modeRadioButtonList);
        }
 private void SelectDropDownListItem(ref DnnComboBox ddl, string key)
 {
     if (Settings.ContainsKey(key))
     {
         ddl.ClearSelection();
         var selItem = ddl.FindItemByValue(Convert.ToString(Settings[key]));
         if (selItem != null)
         {
             selItem.Selected = true;
         }
     }
 }
Esempio n. 14
0
        private void BindConfigForm()
        {
            var folders = FileSystemUtils.GetFoldersByUser(PortalSettings.PortalId, true, true, "READ");
            this.plhConfig.Controls.Clear();
            var pnlContent = new Panel { CssClass = "pcContent" };

            HtmlGenericControl fsContent = null;
            int i = 0;

            foreach (ConfigInfo objConfig in this.DefaultConfig)
            {
                string key = objConfig.Key;
                string value = objConfig.Value;

                if (objConfig.IsSeparator)
                {
                    if (i > 0)
                    {
                        // it's currently a separator, so if its not the first item it needs to close the previous 'feildset'
                        pnlContent.Controls.Add(fsContent);
                    }

                    i += 1;

                    var localizedTitle = Localization.GetString(key + ".Title", LocalResourceFile);
                    if (string.IsNullOrEmpty(localizedTitle))
                    {
                        localizedTitle = key;
                    }

                    pnlContent.Controls.Add(
                        new LiteralControl(
                            "<h2 id='Panel-ProviderConfig-" + i + "' class='dnnFormSectionHead'><a class='dnnSectionExpanded' href=\"\">"
                            + localizedTitle + "</a></h2>"));
                    fsContent = new HtmlGenericControl("fieldset");
                }
                else
                {
                    var pnlRow = new Panel { CssClass = "dnnFormItem" }; // a row starts here and ends at the right before next, where it is added to the fieldset)
                    pnlRow.Controls.Add(this.BuildLabel(key));

                    switch (key.ToLower())
                    {
                        case "stripformattingoptions":
                            {
                                var ctl = new CheckBoxList { ID = "ctl_rc_" + key, RepeatColumns = 2, CssClass = "dnnCBItem" };

                                foreach (string objEnum in Enum.GetNames(typeof(Telerik.Web.UI.EditorStripFormattingOptions)))
                                {
                                    if (objEnum != "All" && objEnum != "None")
                                    {
                                        ctl.Items.Add(new ListItem(objEnum, objEnum));
                                    }
                                }

                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "toolbarmode":
                            {
                                var ctl = new RadioButtonList { ID = "ctl_rc_" + key, RepeatColumns = 2, CssClass = "dnnFormRadioButtons" };

                                foreach (string objEnum in Enum.GetNames(typeof(Telerik.Web.UI.EditorToolbarMode)))
                                {
                                    ctl.Items.Add(new ListItem(objEnum, objEnum));
                                }

                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "editmodes":
                            {
                                var ctl = new CheckBoxList { ID = "ctl_rc_" + key, RepeatColumns = 1, CssClass = "dnnCBItem" };

                                foreach (string objEnum in Enum.GetNames(typeof(Telerik.Web.UI.EditModes)))
                                {
                                    if (objEnum != "All")
                                    {
                                        ctl.Items.Add(new ListItem(objEnum, objEnum));
                                    }
                                }

                                pnlRow.Controls.Add(ctl);
                                break;
                            }
                        case "contentfilters":
                            {
                                var ctl = new CheckBoxList();
                                ctl.ID = "ctl_rc_" + key;
                                ctl.RepeatColumns = 2;
                                ctl.CssClass = "dnnCBItem";

                                foreach (string objEnum in Enum.GetNames(typeof(Telerik.Web.UI.EditorFilters)))
                                {
                                    if (objEnum != "None" && objEnum != "DefaultFilters")
                                    {
                                        ctl.Items.Add(new ListItem(objEnum, objEnum));
                                    }
                                }

                                pnlRow.Controls.Add(ctl);
                                break;
                            }
                        case "imagespath":
                        case "mediapath":
                        case "documentspath":
                        case "flashpath":
                        case "silverlightpath":
                        case "templatepath":
                            {
                                var ctl = new DnnComboBox { ID = "ctl_rc_" + key };
                                // ctl.Width = Unit.Pixel(253)
                                ctl.Items.Clear();

                                foreach (FolderInfo oFolder in folders)
                                {
                                    if (!oFolder.FolderPath.ToLower().StartsWith("cache"))
                                    {
                                        if (oFolder.FolderPath == string.Empty)
                                        {
                                            ctl.AddItem(Localization.GetString("PortalRoot", this.LocalResourceFile), "/");

                                            ctl.AddItem(Localization.GetString("UserFolder", this.LocalResourceFile), "[UserFolder]");
                                        }
                                        else
                                        {
                                            ctl.AddItem(oFolder.FolderPath, oFolder.FolderPath);
                                        }
                                    }
                                }

                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "skin":
                            {
                                var ctl = new DnnComboBox { ID = "ctl_rc_" + key };
                                ctl.AddItem("Default", "Default");
                                ctl.AddItem("Black", "Black");
                                ctl.AddItem("Sunset", "Sunset");
                                ctl.AddItem("Hay", "Hay");
                                ctl.AddItem("Forest", "Forest");
                                ctl.AddItem("Vista", "Vista");

                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "linkstype":
                            {
                                var ctl = new DnnComboBox { ID = "ctl_rc_" + key };
                                ctl.AddItem(this.LocalizeString("LinksType_Normal"), "Normal");
                                ctl.AddItem(this.LocalizeString("LinksType_UseTabName"), "UseTabName");
                                ctl.AddItem(this.LocalizeString("LinksType_UseTabId"), "UseTabId");

                                pnlRow.Controls.Add(ctl);
                            }

                            break;
                        case "enableresize":
                        case "allowscripts":
                        case "showportallinks":
                        case "autoresizeheight":
                        case "linksuserelativeurls":
                        case "newlinebr":
                            {
                                var ctl = new CheckBox { ID = "ctl_rc_" + key, CssClass = "dnnCBItem" };

                                pnlRow.Controls.Add(ctl);
                                break;
                            }
                        case "borderwidth":
                        case "height":
                        case "width":
                        case "toolswidth":
                            {
                                var ctl = new TextBox { Text = @"5", CssClass = "SpinnerStepOne", ID = "ctl_rc_" + key };
                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "maxflashsize":
                        case "maxsilverlightsize":
                        case "maxtemplatesize":
                        case "maximagesize":
                        case "maxdocumentsize":
                        case "maxmediasize":
                            {
                                var ctl = new TextBox { Text = @"1024", CssClass = "SpinnerStep1024", ID = "ctl_rc_" + key };
                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "contentareamode":
                            {
                                var ctl = new DnnComboBox { ID = "ctl_rc_" + key };

                                foreach (string name in Enum.GetNames(typeof(EditorContentAreaMode)))
                                {
                                    if (name != "All")
                                    {
                                        ctl.AddItem(name, name);
                                    }
                                }

                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        case "language":
                            {
                                var ctl = new DnnLanguageComboBox
                                              {
                                                  ID = "ctl_rc_" + key,
                                                  LanguagesListType = LanguagesListType.All,
                                                  IncludeNoneSpecified = true,
                                                  CssClass = "languageComboBox"
                                              };
                                pnlRow.Controls.Add(ctl);
                                break;
                            }

                        default:
                            {
                                var ctl = new TextBox { ID = "ctl_rc_" + key, Text = value };
                                pnlRow.Controls.Add(ctl);
                                break;
                            }
                    }

                    fsContent.Controls.Add(pnlRow);
                }
            }

            pnlContent.Controls.Add(fsContent);

            plhConfig.Controls.Add(pnlContent);
        }
        protected override WebControl CreateControlInternal(Control container)
        {
            //ComboBox = new DropDownList { ID = ID + "_ComboBox" };
            ComboBox = new DnnComboBox { ID = ID + "_ComboBox" };
            ComboBox.SelectedIndexChanged += IndexChanged;
            container.Controls.Add(ComboBox);

            if (ListSource != null)
            {
                BindList();
            }

            return ComboBox;
        }