/// <summary> /// Gets the effective PanelType, coalescing this.PanelType, the parent AccordionControl's DefaultPanelType, /// and ContextStyles.Default. /// </summary> /// <returns>The first non-null PanelType.</returns> private PanelTypes GetPanelType() { if (this.PanelType.HasValue) { return(this.PanelType.Value); } AccordionControl accordionControl = this.Parent as AccordionControl; if (accordionControl != null && accordionControl.DefaultPanelType.HasValue) { return(accordionControl.DefaultPanelType.Value); } return(PanelTypes.Default); }
/// <summary> /// Renders the HTML contents of the control into the specified <paramref name="writer"/>. /// </summary> /// <param name="writer">A <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param> protected override void RenderContents(HtmlTextWriter writer) { AccordionPane pane = this.Parent as AccordionPane; if (pane == null) { throw new System.InvalidCastException("AccordionContentHeaderPanel must be the child of an AccordionPane"); } AccordionControl accordion = this.Parent.Parent as AccordionControl; if (accordion == null) { throw new System.InvalidCastException("AccordionContentHeaderPanel must be the grandchild of an AccordionControl"); } writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel-title"); writer.RenderBeginTag(accordion.HeaderTagType); writer.AddAttribute(HtmlTextWriterAttribute.Href, "#" + pane.BodyClientID); writer.AddAttribute("role", "button"); writer.AddAttribute("data-toggle", "collapse"); // leave off data-parent if MultiSelectable is true on the AccordionControl if (!accordion.MultiSelectable) { writer.AddAttribute("data-parent", "#" + accordion.ClientID); } // add ARIA markup writer.AddAttribute("aria-expanded", StringHelper.ToLower(pane.Expanded)); writer.AddAttribute("aria-controls", pane.BodyClientID); writer.RenderBeginTag(HtmlTextWriterTag.A); base.RenderContents(writer); writer.RenderEndTag(); writer.RenderEndTag(); }