Inheritance: System.Web.UI.WebControls.Panel, INamingContainer, IDataItemContainer
Esempio n. 1
0
        /// <summary>
        /// Instantiate the templates into new child controls
        /// </summary>
        protected override void CreateChildControls()
        {
            // Create the controls
            Controls.Clear();
            _header    = new AccordionContentPanel(null, -1, AccordionItemType.Header);
            _header.ID = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_header", this.ID);
            Controls.Add(_header);
            _content    = new AccordionContentPanel(null, -1, AccordionItemType.Content);
            _content.ID = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_content", this.ID);
            Controls.Add(_content);

            // By default, collapse the content sections so the
            // page loads without flicker (the selected section
            // will be expanded again in the parent Accordion's
            // OnPreRender)
            _content.Collapsed = true;

            // Load the templates into the controls
            if (_headerTemplate != null)
            {
                _headerTemplate.InstantiateIn(_header);
            }
            if (_contentTemplate != null)
            {
                _contentTemplate.InstantiateIn(_content);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Mark the selected AccordionPane so it does not appear collapsed
        /// </summary>
        /// <param name="e">EventArgs</param>
        protected override void OnPreRender(EventArgs e)
        {
            EnsureDataBound();
            base.OnPreRender(e);

            // Set the overflow to hidden to prevent any growth from
            // showing initially before it is hidden by the script if
            // we are controlling the height
            if (AutoSize != AutoSize.None)
            {
                Style[HtmlTextWriterStyle.Overflow]  = "hidden";
                Style[HtmlTextWriterStyle.OverflowX] = "auto";
            }

            // Apply the standard header/content styles, but allow the
            // pane's styles to take precedent
            foreach (AccordionPane pane in Panes)
            {
                if (pane.HeaderCssClass == HeaderSelectedCssClass)
                {
                    pane.HeaderCssClass = string.Empty;
                }
                if (!string.IsNullOrEmpty(HeaderCssClass) && string.IsNullOrEmpty(pane.HeaderCssClass))
                {
                    pane.HeaderCssClass = HeaderCssClass;
                }
                if (!string.IsNullOrEmpty(ContentCssClass) && string.IsNullOrEmpty(pane.ContentCssClass))
                {
                    pane.ContentCssClass = ContentCssClass;
                }
            }

            // Get the index of the selected pane, or use the first pane if we don't
            // have a valid index and require one.  (Note: We don't reset the SelectedIndex
            // property because it may refer to a pane that will be added dynamically on the
            // client.  If we need to start with a pane visible, then we'll open the first
            // pane because that's the default value used on the client as the SelectedIndex
            // in this scenario.)
            int index = AccordionExtender.SelectedIndex;

            index = ((index < 0 || index >= Panes.Count) && AccordionExtender.RequireOpenedPane) ? 0 : index;

            // Make sure the selected pane is displayed
            if (index >= 0 && index < Panes.Count)
            {
                AccordionContentPanel content = Panes[index].ContentContainer;
                if (content != null)
                {
                    content.Collapsed = false;
                }

                // Set the CSS class for the open panes header
                if (!string.IsNullOrEmpty(HeaderSelectedCssClass))
                {
                    Panes[index].HeaderCssClass = HeaderSelectedCssClass;
                }
            }
        }
Esempio n. 3
0
        // Create an AccordionPane's item (either Header or Content) and raise the ItemCreated event
        void CreateItem(object dataItem, int index, AccordionItemType itemType, AccordionContentPanel container, ITemplate template, bool dataBind)
        {
            if (template == null)
            {
                return;
            }

            var itemArgs = new AccordionItemEventArgs(container, itemType);

            OnItemCreated(itemArgs);

            container.SetDataItemProperties(dataItem, index, itemType);
            template.InstantiateIn(container);

            if (dataBind)
            {
                container.DataBind();
                OnItemDataBound(itemArgs);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Instantiate the templates into new child controls
        /// </summary>
        protected override void CreateChildControls()
        {
            // Create the controls
            Controls.Clear();
            Controls.Add(_header  = new AccordionContentPanel(null, -1, AccordionItemType.Header));
            Controls.Add(_content = new AccordionContentPanel(null, -1, AccordionItemType.Content));

            // By default, collapse the content sections so the
            // page loads without flicker (the selected section
            // will be expanded again in the parent Accordion's
            // OnPreRender)
            _content.Collapsed = true;

            // Load the templates into the controls
            if (_headerTemplate != null)
            {
                _headerTemplate.InstantiateIn(_header);
            }
            if (_contentTemplate != null)
            {
                _contentTemplate.InstantiateIn(_content);
            }
        }
 public AccordionItemEventArgs(AccordionContentPanel item, AccordionItemType type)
 {
     _item = item;
     _type = type;
 }
Esempio n. 6
0
        /// <summary>
        /// Create an AccordionPane's item (either Header or Content) and raise the ItemCreated event
        /// </summary>
        /// <param name="dataItem">Item's data</param>
        /// <param name="index">Index</param>
        /// <param name="itemType">Type of the item (Header or Content)</param>
        /// <param name="container">Control to fill</param>
        /// <param name="template">Template for the binding</param>
        /// <param name="dataBind">Whether or not to bind</param>
        private void CreateItem(object dataItem, int index, AccordionItemType itemType, AccordionContentPanel container, ITemplate template, bool dataBind)
        {

            if (template == null)
                return;

            AccordionItemEventArgs itemArgs = new AccordionItemEventArgs(container, itemType);
            OnItemCreated(itemArgs);

            container.SetDataItemProperties(dataItem, index, itemType);
            template.InstantiateIn(container);

            if (dataBind)
            {
                container.DataBind();
                OnItemDataBound(itemArgs);
            }
        }
 public AccordionItemEventArgs(AccordionContentPanel item, AccordionItemType type)
 {
     _item = item;
     _type = type;
 }
Esempio n. 8
0
        /// <summary>
        /// Instantiate the templates into new child controls
        /// </summary>
        protected override void CreateChildControls()
        {
            // Create the controls
            Controls.Clear();
            Controls.Add(_header = new AccordionContentPanel(null, -1, AccordionItemType.Header));
            Controls.Add(_content = new AccordionContentPanel(null, -1, AccordionItemType.Content));

            // By default, collapse the content sections so the
            // page loads without flicker (the selected section
            // will be expanded again in the parent Accordion's
            // OnPreRender)
            _content.Collapsed = true;

            // Load the templates into the controls
            if (_headerTemplate != null)
                _headerTemplate.InstantiateIn(_header);
            if (_contentTemplate != null)
                _contentTemplate.InstantiateIn(_content);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="container">Container</param>
 /// <param name="commandName">Command Name</param>
 /// <param name="commandArg">Command Argument</param>
 internal AccordionCommandEventArgs(AccordionContentPanel container, string commandName, object commandArg)
     : base(commandName, commandArg)
 {
     _container = container;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="container">Container</param>
 /// <param name="commandName">Command Name</param>
 /// <param name="commandArg">Command Argument</param>
 internal AccordionCommandEventArgs(AccordionContentPanel container, string commandName, object commandArg)
     : base(commandName, commandArg)
 {
     _container = container;
 }
        /// <summary>
        /// Instantiate the templates into new child controls
        /// </summary>
        protected override void CreateChildControls()
        {
            // Create the controls
            Controls.Clear();
            _header = new AccordionContentPanel(null, -1, AccordionItemType.Header);
            _header.ID = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_header", this.ID);
            Controls.Add(_header);
            _content = new AccordionContentPanel(null, -1, AccordionItemType.Content);
            _content.ID = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_content", this.ID);
            Controls.Add(_content);

            // By default, collapse the content sections so the
            // page loads without flicker (the selected section
            // will be expanded again in the parent Accordion's
            // OnPreRender)
            _content.Collapsed = true;

            // Load the templates into the controls
            if (_headerTemplate != null)
                _headerTemplate.InstantiateIn(_header);
            if (_contentTemplate != null)
                _contentTemplate.InstantiateIn(_content);
        }