Click here to Skip to main content
15,895,784 members
Articles / Web Development / ASP.NET

Source Code for JQuery ASP.NET Controls

Rate me:
Please Sign up or sign in to vote.
4.56/5 (15 votes)
10 Jun 2009CPOL 67.6K   3.7K   93  
Get a start to building your own JQuery Controls
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Mullivan.Web.UI.WebControls
{

    public class JQueryAccordionSectionCollection : IList, ICollection, IEnumerable
    {
        private JQueryAccordion _owner = null;

        internal JQueryAccordionSectionCollection(JQueryAccordion owner)
        {
            this._owner = owner;
        }

        public void Add(JQueryAccordionSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("wizardStep");
            }
            this.RemoveIfAlreadyExistsInsections(section);
            section.PreventAutoID();
            section.SetOwner(this._owner);
            this.Sections.Add(section);
            this.NotifysectionsChanged();
        }

        public void AddAt(int index, JQueryAccordionSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            this.RemoveIfAlreadyExistsInsections(section);
            section.PreventAutoID();
            section.SetOwner(this._owner);
            this.Sections.AddAt(index, section);
            this.NotifysectionsChanged();
        }

        public void Clear()
        {
            this.Sections.Clear();
            this.NotifysectionsChanged();
        }

        public bool Contains(JQueryAccordionSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            return this.Sections.Contains(section);
        }

        public void CopyTo(JQueryAccordionSection[] array, int index)
        {
            this.Sections.CopyTo(array, index);
        }

        public IEnumerator GetEnumerator()
        {
            return this.Sections.GetEnumerator();
        }

        private JQueryAccordionSection GetSectionAndVerify(object value)
        {
            JQueryAccordionSection base2 = value as JQueryAccordionSection;
            if (base2 == null)
            {
                throw new ArgumentException("Invalid type. Must be JQueryAccordionSection.");
            }
            return base2;
        }

        public int IndexOf(JQueryAccordionSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            return this.Sections.IndexOf(section);
        }

        public void Insert(int index, JQueryAccordionSection section)
        {
            this.AddAt(index, section);
        }

        internal void NotifysectionsChanged()
        {
        }

        public void Remove(JQueryAccordionSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            this.Sections.Remove(section);
            section.SetOwner(null);
            this.NotifysectionsChanged();
        }

        public void RemoveAt(int index)
        {
            JQueryAccordionSection base2 = this.Sections[index] as JQueryAccordionSection;
            if (base2 != null)
            {
                base2.SetOwner(null);
            }
            this.Sections.RemoveAt(index);
            this.NotifysectionsChanged();
        }

        private void RemoveIfAlreadyExistsInsections(JQueryAccordionSection section)
        {
            if (section.Owner != null)
            {
                section.Owner.Sections.Remove(section);
            }
        }

        void ICollection.CopyTo(Array array, int index)
        {
            this.Sections.CopyTo(array, index);
        }

        int IList.Add(object value)
        {
            JQueryAccordionSection stepAndVerify = this.GetSectionAndVerify(value);
            this.Add(stepAndVerify);
            return this.IndexOf(stepAndVerify);
        }

        bool IList.Contains(object value)
        {
            return this.Contains(this.GetSectionAndVerify(value));
        }

        int IList.IndexOf(object value)
        {
            return this.IndexOf(this.GetSectionAndVerify(value));
        }

        void IList.Insert(int index, object value)
        {
            this.AddAt(index, this.GetSectionAndVerify(value));
        }

        void IList.Remove(object value)
        {
            this.Remove(this.GetSectionAndVerify(value));
        }

        // Properties
        public int Count
        {
            get
            {
                return this.Sections.Count;
            }
        }

        public bool IsReadOnly
        {
            get
            {
                return this.Sections.IsReadOnly;
            }
        }

        public bool IsSynchronized
        {
            get
            {
                return false;
            }
        }

        public JQueryAccordionSection this[int index]
        {
            get
            {
                return (JQueryAccordionSection)this.Sections[index];
            }
        }

        public object SyncRoot
        {
            get
            {
                return this;
            }
        }

        bool IsFixedSize
        {
            get
            {
                return false;
            }
        }

        bool IList.IsFixedSize
        {
            get
            {
                return false;
            }
        }

        object IList.this[int index]
        {
            get
            {
                return this.Sections[index];
            }
            set
            {
                this.RemoveAt(index);
                this.AddAt(index, this.GetSectionAndVerify(value));
            }
        }

        private JQueryAccordionSectionControlCollection Sections
        {
            get
            {
                return this._owner.SectionControls;
            }
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions