示例#1
0
        protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            this.HasLoadPostData = true;

            string state = postCollection[this.UniqueName];

            this.SuspendScripting();
            this.RawValue = state;
            this.ResumeScripting();

            if (state == null)
            {
                return(false);
            }

            if (state.IsNotEmpty())
            {
                try
                {
                    List <ListItem> items = ComboBoxBase.ParseSelectedItems(state);

                    bool fireEvent = false;

                    foreach (ListItem item in items)
                    {
                        if (!this.SelectedItems.Contains(item))
                        {
                            fireEvent = true;
                            break;
                        }
                    }

                    this.SelectedItems.Clear();
                    this.SelectedItems.AddRange(items);

                    return(fireEvent);
                }
                catch
                {
                    this.SuccessLoadPostData = false;
                    if (this.RethrowLoadPostDataException)
                    {
                        throw;
                    }
                }
            }
            else
            {
                if (this.SelectedItems.Count > 0)
                {
                    this.SelectedItems.Clear();

                    return(true);
                }
            }

            return(false);
        }
        protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            this.HasLoadPostData = true;

            string text  = postCollection[this.UniqueName];
            string state = postCollection[this.ValueHiddenName.IsNotEmpty() ? this.ValueHiddenName : ("_" + this.UniqueName + "_state")];

            this.SuspendScripting();
            this.RawValue = text;
            this.Value    = text;
            this.ResumeScripting();

            if (state == null && text == null)
            {
                return(false);
            }

            try
            {
                this.SuspendScripting();
                if (!this.EmptyText.Equals(text) && text.IsNotEmpty())
                {
                    List <ListItem> items = null;

                    if (this.SimpleSubmit)
                    {
                        string[] array = state.Split(new char[] { ',' });

                        items = new List <ListItem>(array.Length);

                        foreach (string item in array)
                        {
                            items.Add(new ListItem(item));
                        }
                    }
                    else if (state.IsNotEmpty())
                    {
                        items = ComboBoxBase.ParseSelectedItems(state);
                    }

                    bool fireEvent = false;

                    if (items == null)
                    {
                        items = new List <ListItem>
                        {
                            new ListItem(text)
                        };
                    }

                    foreach (ListItem item in items)
                    {
                        if (!this.SelectedItems.Contains(item))
                        {
                            fireEvent = true;
                            break;
                        }
                    }

                    this.SelectedItems.Clear();
                    this.SelectedItems.AddRange(items);

                    if (this.SelectedItems.Count > 0)
                    {
                        this.Value = this.SelectedItems[0].Value;
                    }

                    return(fireEvent);
                }
                else
                {
                    if (this.EmptyText.Equals(text) && this.SelectedItems.Count > 0)
                    {
                        this.SelectedItems.Clear();

                        return(true);
                    }
                }
            }
            catch
            {
                this.SuccessLoadPostData = false;
                if (this.RethrowLoadPostDataException)
                {
                    throw;
                }
            }
            finally
            {
                this.ResumeScripting();
            }

            return(false);
        }
示例#3
0
        protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            this.HasLoadPostData = true;

            string text  = postCollection[this.UniqueName];
            string state = postCollection["_" + this.UniqueName + "_state"];

            this.SuspendScripting();
            this.RawValue = text;
            this.Value    = text;
            this.ResumeScripting();

            if (state == null && text == null)
            {
                return(false);
            }

            if (!this.EmptyText.Equals(text) && text.IsNotEmpty())
            {
                List <ListItem> items = null;
                if (this.SimpleSubmit)
                {
                    var array = state.Split(new char[] { ',' });
                    items = new List <ListItem>(array.Length);
                    foreach (var item in array)
                    {
                        items.Add(new ListItem(item));
                    }
                }
                else if (state.IsNotEmpty())
                {
                    items = ComboBoxBase.ParseSelectedItems(state);
                }

                bool fireEvent = false;

                if (items == null)
                {
                    items = new List <ListItem>
                    {
                        new ListItem(text)
                    };

                    /*fireEvent = this.SelectedItems.Count > 0;
                     * this.SelectedItems.Clear();
                     * return fireEvent;
                     */
                }

                foreach (var item in items)
                {
                    if (!this.SelectedItems.Contains(item))
                    {
                        fireEvent = true;
                        break;
                    }
                }

                this.SelectedItems.Clear();
                this.SelectedItems.AddRange(items);

                return(fireEvent);
            }
            else
            {
                if (this.EmptyText.Equals(text) && this.SelectedItems.Count > 0)
                {
                    this.SelectedItems.Clear();

                    return(true);
                }
            }

            return(false);
        }