Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // get PreValues, load them into the controls.
            var options = this.GetPreValueOptions <UserPickerOptions>();

            // no options? use the default ones.
            if (options == null)
            {
                options = new UserPickerOptions(true);
            }

            // set the values
            this.ListControlType.SelectedIndex = options.UseDropDown ? 0 : 1;

            if (options.SelectedUserTypes != null && options.SelectedUserTypes.Length > 0)
            {
                var selectedUserTypes = new List <string>(options.SelectedUserTypes);
                foreach (ListItem item in this.UserTypesList.Items)
                {
                    if (selectedUserTypes.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the data-type PreValue options.
        /// </summary>
        public override void Save()
        {
            // set the options
            var options = new UserPickerOptions(true);

            options.UseDropDown       = this.ListControlType.SelectedIndex == 0;
            options.SelectedUserTypes = this.UserTypesList.Items.Cast <ListItem>().Where(i => i.Selected == true).Select(i => i.Value).ToArray();

            // save the options as JSON
            this.SaveAsJson(options);
        }
        /// <summary>
        /// Saves the data-type PreValue options.
        /// </summary>
        public override void Save()
        {
            // set the options
            var options = new UserPickerOptions(true);

            options.UseDropDown = this.ListControlType.SelectedIndex == 0;
            options.SelectedUserTypes = this.UserTypesList.Items.Cast<ListItem>().Where(i => i.Selected == true).Select(i => i.Value).ToArray();

            // save the options as JSON
            this.SaveAsJson(options);
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // get PreValues, load them into the controls.
            var options = this.GetPreValueOptions<UserPickerOptions>();

            // no options? use the default ones.
            if (options == null)
            {
                options = new UserPickerOptions(true);
            }

            // set the values
            this.ListControlType.SelectedIndex = options.UseDropDown ? 0 : 1;

            if (options.SelectedUserTypes != null && options.SelectedUserTypes.Length > 0)
            {
                var selectedUserTypes = new List<string>(options.SelectedUserTypes);
                foreach (ListItem item in this.UserTypesList.Items)
                {
                    if (selectedUserTypes.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }
            }
        }