/// <summary> /// Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's <see cref="T:System.Web.UI.ControlCollection" /> object. /// </summary> /// <param name="obj">An <see cref="T:System.Object" /> that represents the parsed element.</param> protected override void AddParsedSubObject(object obj) { CarouselItem item = obj as CarouselItem; if (item != null) { this.Items.Add(item); } }
/// <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) { this.RenderIndicators(writer); writer.AddAttribute(HtmlTextWriterAttribute.Class, "carousel-inner"); writer.RenderBeginTag(HtmlTextWriterTag.Div); for (int i = 0; i < this.Items.Count; i++) { CarouselItem item = this.Items[i]; bool isActive = this.ActiveCarouselItem == i; string cssClass = StringHelper.AppendIf("item", isActive, " active"); writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass); writer.RenderBeginTag(HtmlTextWriterTag.Div); item.RenderControl(writer); writer.RenderEndTag(); // Div } writer.RenderEndTag(); // Div }