Example #1
0
        /// <devdoc>
        ///    <para>Renders the Repeater with the specified
        ///       information.</para>
        /// </devdoc>
        public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            if (IsListLayout)
            {
                if (user.HasFooter || user.HasHeader || user.HasSeparators)
                {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutDoesNotSupportHeaderFooterSeparator));
                }
                if (RepeatDirection != RepeatDirection.Vertical)
                {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutOnlySupportsVerticalLayout));
                }
                if ((RepeatColumns != 0) && (RepeatColumns != 1))
                {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutDoesNotSupportMultipleColumn));
                }
                if (OuterTableImplied)
                {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutDoesNotSupportImpliedOuterTable));
                }
            }

            if (repeatDirection == RepeatDirection.Vertical)
            {
                RenderVerticalRepeater(writer, user, controlStyle, baseControl);
            }
            else
            {
                RenderHorizontalRepeater(writer, user, controlStyle, baseControl);
            }
        }
Example #2
0
 public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
 {
     if (this.IsListLayout)
     {
         if ((user.HasFooter || user.HasHeader) || user.HasSeparators)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutDoesNotSupportHeaderFooterSeparator"));
         }
         if (this.RepeatDirection != System.Web.UI.WebControls.RepeatDirection.Vertical)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutOnlySupportsVerticalLayout"));
         }
         if ((this.RepeatColumns != 0) && (this.RepeatColumns != 1))
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutDoesNotSupportMultipleColumn"));
         }
         if (this.OuterTableImplied)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutDoesNotSupportImpliedOuterTable"));
         }
     }
     if (this.repeatDirection == System.Web.UI.WebControls.RepeatDirection.Vertical)
     {
         this.RenderVerticalRepeater(writer, user, controlStyle, baseControl);
     }
     else
     {
         this.RenderHorizontalRepeater(writer, user, controlStyle, baseControl);
     }
 }
Example #3
0
		// What is baseControl for ?
		public void RenderRepeater (HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
		{
			PrintValues (user);
			RepeatLayout layout = RepeatLayout;
			bool listLayout = layout == RepeatLayout.OrderedList || layout == RepeatLayout.UnorderedList;

			if (listLayout) {
				if (user != null) {
					if ((user.HasHeader || user.HasFooter || user.HasSeparators))
						throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support headers, footers or separators.");
				}

				if (OuterTableImplied)
					throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.");

				int cols = RepeatColumns;
				if (cols > 1)
					throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.");
			}
			if (RepeatDirection == RepeatDirection.Vertical) {
				if (listLayout)
					RenderList (w, user, controlStyle, baseControl);
				else
					RenderVert (w, user, controlStyle, baseControl);
			} else {
				if (listLayout)
						throw new InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.");
				RenderHoriz (w, user, controlStyle, baseControl);
			}
		}
		// What is baseControl for ?
		public void RenderRepeater (HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
		{
			PrintValues (user);

			if (RepeatDirection == RepeatDirection.Vertical)
				RenderVert (w, user, controlStyle, baseControl);
			else
				RenderHoriz (w, user, controlStyle, baseControl);
		}
Example #5
0
 /// <include file='doc\RepeatInfo.uex' path='docs/doc[@for="RepeatInfo.RenderRepeater"]/*' />
 /// <devdoc>
 ///    <para>Renders the Repeater with the specified
 ///       information.</para>
 /// </devdoc>
 public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
 {
     if (repeatDirection == RepeatDirection.Vertical)
     {
         RenderVerticalRepeater(writer, user, controlStyle, baseControl);
     }
     else
     {
         RenderHorizontalRepeater(writer, user, controlStyle, baseControl);
     }
 }
Example #6
0
        public void RepeatInfoCount()
        {
            CheckBoxList    c  = new CheckBoxList();
            IRepeatInfoUser ri = (IRepeatInfoUser)c;

            Assert.AreEqual(ri.RepeatedItemCount, 0, "A1");

            c.Items.Add("one");
            c.Items.Add("two");
            c.Items.Add("three");
            Assert.AreEqual(ri.RepeatedItemCount, 3, "A2");
        }
Example #7
0
        // What is baseControl for ?
        public void RenderRepeater(HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            PrintValues(user);

            if (RepeatDirection == RepeatDirection.Vertical)
            {
                RenderVert(w, user, controlStyle, baseControl);
            }
            else
            {
                RenderHoriz(w, user, controlStyle, baseControl);
            }
        }
Example #8
0
        // What is baseControl for ?
        public void RenderRepeater(HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            PrintValues(user);
#if NET_4_0
            RepeatLayout layout     = RepeatLayout;
            bool         listLayout = layout == RepeatLayout.OrderedList || layout == RepeatLayout.UnorderedList;

            if (listLayout)
            {
                if (user != null)
                {
                    if ((user.HasHeader || user.HasFooter || user.HasSeparators))
                    {
                        throw new InvalidOperationException("The UnorderedList and OrderedList layouts do not support headers, footers or separators.");
                    }
                }

                if (OuterTableImplied)
                {
                    throw new InvalidOperationException("The UnorderedList and OrderedList layouts do not support implied outer tables.");
                }

                int cols = RepeatColumns;
                if (cols > 1)
                {
                    throw new InvalidOperationException("The UnorderedList and OrderedList layouts do not support multi-column layouts.");
                }
            }
#endif
            if (RepeatDirection == RepeatDirection.Vertical)
            {
#if NET_4_0
                if (listLayout)
                {
                    RenderList(w, user, controlStyle, baseControl);
                }
                else
#endif
                RenderVert(w, user, controlStyle, baseControl);
            }
            else
            {
#if NET_4_0
                if (listLayout)
                {
                    throw new InvalidOperationException("The UnorderedList and OrderedList layouts only support vertical layout.");
                }
#endif
                RenderHoriz(w, user, controlStyle, baseControl);
            }
        }
Example #9
0
        internal void PrintValues(IRepeatInfoUser riu)
        {
            string s = String.Format("Layout {0}; Direction {1}; Cols {2}; OuterTableImplied {3}\n" +
                                     "User: itms {4}, hdr {5}; ftr {6}; sep {7}", RepeatLayout, RepeatDirection,
                                     RepeatColumns, OuterTableImplied, riu.RepeatedItemCount, riu.HasSeparators, riu.HasHeader,
                                     riu.HasFooter, riu.HasSeparators
                                     );

            Console.WriteLine(s);
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Trace.Write(s);
            }
        }
Example #10
0
        public void RepeatInfoRenderItem()
        {
            StringWriter    sw = new StringWriter();
            HtmlTextWriter  tw = new HtmlTextWriter(sw);
            CheckBoxList    c  = new CheckBoxList();
            IRepeatInfoUser ri = (IRepeatInfoUser)c;
            RepeatInfo      r  = new RepeatInfo();

            c.Items.Add("one");
            c.Items.Add("two");

            ri.RenderItem(ListItemType.Item, 0, r, tw);
            Assert.AreEqual("<input id=\"0\" type=\"checkbox\" name=\"0\" />" +
                            "<label for=\"0\">one</label>", sw.ToString(), "A1");
        }
        protected override void OnPreRender(System.EventArgs e)
        {
            // Call the base class's OnPreRender method
            base.OnPreRender(e);

            // Get a self-referencing IRepeatInfoUser object
            IRepeatInfoUser repeatInfoUser = (IRepeatInfoUser)this;

            // Get the IRepeatInfoUser members values.
            hasFooter         = repeatInfoUser.HasFooter;
            hasHeader         = repeatInfoUser.HasHeader;
            hasSeparators     = repeatInfoUser.HasSeparators;
            repeatedItemCount = repeatInfoUser.RepeatedItemCount;
            itemStyleItem     = repeatInfoUser.GetItemStyle(ListItemType.Item, 0);
        }
Example #12
0
		void RenderList (HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
		{
			int items = user.RepeatedItemCount;
			RenderBeginTag (w, controlStyle, baseControl);

			for (int i = 0; i < items; i++) {
				// Style s = null;
				// s = user.GetItemStyle (ListItemType.Item, i);
				// if (s != null)
				// 	s.AddAttributesToRender (w);
				w.RenderBeginTag (HtmlTextWriterTag.Li);
				user.RenderItem (ListItemType.Item, i, this, w);
				w.RenderEndTag (); // </li>
				w.WriteLine ();
			}
			
			w.RenderEndTag ();
		}
        protected override void Render(HtmlTextWriter writer)
        {
            // Create and setup a RepeatInfo class.
            RepeatInfo repeatInfo = new RepeatInfo();

            repeatInfo.RepeatColumns   = 0;
            repeatInfo.RepeatDirection = RepeatDirection.Horizontal;
            repeatInfo.RepeatLayout    = RepeatLayout.Table;

            // Get a self-referencing IRepeatInfoUser object
            IRepeatInfoUser repeatInfoUser = (IRepeatInfoUser)this;

            // Render the items using the above RepeatInfo class.
            repeatInfoUser.RenderItem(ListItemType.Item, 0, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 1, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 2, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 3, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 4, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 5, repeatInfo, writer);
        }
Example #14
0
        public void RepeatInfoRenderItem()
        {
#if NET_4_0
            string origHtml = "<input id=\"0\" type=\"checkbox\" name=\"0\" value=\"one\" /><label for=\"0\">one</label>";
#else
            string origHtml = "<input id=\"0\" type=\"checkbox\" name=\"0\" /><label for=\"0\">one</label>";
#endif
            StringWriter    sw = new StringWriter();
            HtmlTextWriter  tw = new HtmlTextWriter(sw);
            CheckBoxList    c  = new CheckBoxList();
            IRepeatInfoUser ri = (IRepeatInfoUser)c;
            RepeatInfo      r  = new RepeatInfo();

            c.Items.Add("one");
            c.Items.Add("two");

            ri.RenderItem(ListItemType.Item, 0, r, tw);
            string html = sw.ToString();
            Assert.AreEqual(origHtml, html, "A1");
        }
Example #15
0
        void RenderList(HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int items = user.RepeatedItemCount;

            RenderBeginTag(w, controlStyle, baseControl);

            for (int i = 0; i < items; i++)
            {
                // Style s = null;
                // s = user.GetItemStyle (ListItemType.Item, i);
                // if (s != null)
                //  s.AddAttributesToRender (w);
                w.RenderBeginTag(HtmlTextWriterTag.Li);
                user.RenderItem(ListItemType.Item, i, this, w);
                w.RenderEndTag();                  // </li>
                w.WriteLine();
            }

            w.RenderEndTag();
        }
Example #16
0
        void RenderHoriz(HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int itms = user.RepeatedItemCount;
            // total number of rows/columns in our table
            int cols = RepeatColumns == 0 ? itms : RepeatColumns;
            // this gets ceil (itms / cols)
            int  rows = cols == 0 ? 0 : (itms + cols - 1) / cols;
            bool sep  = user.HasSeparators;
            //bool oti = OuterTableImplied;
            int hdr_span = cols * (sep ? 2 : 1);

            bool table = RepeatLayout == RepeatLayout.Table;
            bool show_empty_trailing_items = true;
            bool show_empty_trailing_sep   = true;

            RenderBeginTag(w, controlStyle, baseControl);

            if (Caption.Length > 0)
            {
                if (CaptionAlign != TableCaptionAlign.NotSet)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Align, CaptionAlign.ToString());
                }

                w.RenderBeginTag(HtmlTextWriterTag.Caption);
                w.Write(Caption);
                w.RenderEndTag();
            }

            // Render the header
            if (user.HasHeader)
            {
                if (table)
                {
                    w.RenderBeginTag(HtmlTextWriterTag.Tr);
                    // Make sure the header takes up the full width. We have two
                    // columns per item if we are using separators, otherwise
                    // one per item.
                    if (hdr_span != 1)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Colspan, hdr_span.ToString(), false);
                    }

                    if (UseAccessibleHeader)
                    {
                        w.AddAttribute("scope", "col", false);
                    }

                    Style s = user.GetItemStyle(ListItemType.Header, -1);
                    if (s != null)
                    {
                        s.AddAttributesToRender(w);
                    }

                    if (UseAccessibleHeader)
                    {
                        w.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        w.RenderBeginTag(HtmlTextWriterTag.Td);
                    }

                    user.RenderItem(ListItemType.Header, -1, this, w);
                    w.RenderEndTag();                      // td
                    w.RenderEndTag();                      // tr
                }
                else
                {
                    user.RenderItem(ListItemType.Header, -1, this, w);
                    if (!table && RepeatColumns != 0 && itms != 0)
                    {
                        RenderBr(w);
                    }
                }
            }

            for (int r = 0; r < rows; r++)
            {
                if (table)
                {
                    w.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                for (int c = 0; c < cols; c++)
                {
                    // Find the item number we are in according to the repeat
                    // direction.
                    int item = r * cols + c;

                    // This item is blank because there there not enough items
                    // to make a full row.
                    if (!show_empty_trailing_items && item >= itms)
                    {
                        continue;
                    }

                    if (table)
                    {
                        Style s = null;
                        if (item < itms)
                        {
                            s = user.GetItemStyle(ListItemType.Item, item);
                        }

                        if (s != null)
                        {
                            s.AddAttributesToRender(w);
                        }
                        w.RenderBeginTag(HtmlTextWriterTag.Td);
                    }

                    if (item < itms)
                    {
                        user.RenderItem(ListItemType.Item, item, this, w);
                    }

                    if (table)
                    {
                        w.RenderEndTag();                          // td
                    }
                    if (sep)
                    {
                        if (table)
                        {
                            if (item < itms - 1)
                            {
                                Style s = user.GetItemStyle(ListItemType.Separator, item);
                                if (s != null)
                                {
                                    s.AddAttributesToRender(w);
                                }
                            }
                            if (item < itms - 1 || show_empty_trailing_sep)
                            {
                                w.RenderBeginTag(HtmlTextWriterTag.Td);
                            }
                        }

                        if (item < itms - 1)
                        {
                            user.RenderItem(ListItemType.Separator, item, this, w);
                        }

                        if (table && (item < itms - 1 || show_empty_trailing_sep))
                        {
                            w.RenderEndTag();                              // td
                        }
                    }
                }

                if (table)
                {
                    //	if (!oti)
                    w.RenderEndTag();                              // tr
                }
                else if (!(r == rows - 1 && RepeatColumns == 0))
                {
                    RenderBr(w);
                }
            }

            // Render the footer
            if (user.HasFooter)
            {
                if (table)
                {
                    w.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if (hdr_span != 1)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Colspan, hdr_span.ToString(), false);
                    }

                    Style s = user.GetItemStyle(ListItemType.Footer, -1);
                    if (s != null)
                    {
                        s.AddAttributesToRender(w);
                    }

                    w.RenderBeginTag(HtmlTextWriterTag.Td);
                    user.RenderItem(ListItemType.Footer, -1, this, w);
                    w.RenderEndTag();                      // td
                    w.RenderEndTag();                      // tr
                }
                else
                {
                    user.RenderItem(ListItemType.Footer, -1, this, w);
                }
            }
            if (true)
            {
                w.RenderEndTag();                  // table/span
            }
        }
Example #17
0
        /// <include file='doc\RepeatInfo.uex' path='docs/doc[@for="RepeatInfo.RenderVerticalRepeater"]/*' />
        /// <devdoc>
        /// </devdoc>
        private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int itemCount = user.RepeatedItemCount;
            int totalColumns;
            int totalRows;
            int filledColumns;

            if ((repeatColumns == 0) || (repeatColumns == 1))
            {
                // A RepeatColumns of 0 implies a completely vertical repetition in
                // a single column. This is same as repeatColumns of 1.
                totalColumns  = 1;
                filledColumns = 1;
                totalRows     = itemCount;
            }
            else
            {
                totalColumns = repeatColumns;
                totalRows    = (int)((itemCount + repeatColumns - 1) / repeatColumns);

                if ((totalRows == 0) && (itemCount != 0))
                {
                    // if repeatColumns is a huge number like Int32.MaxValue, then the
                    // calculation above essentially reduces down to 0
                    totalRows    = 1;
                    totalColumns = itemCount;
                }

                filledColumns = itemCount % totalColumns;
                if (filledColumns == 0)
                {
                    filledColumns = totalColumns;
                }
            }


            WebControl outerControl = null;
            bool       tableLayout  = false;

            if (outerTableImplied == false)
            {
                switch (repeatLayout)
                {
                case RepeatLayout.Table:
                    outerControl = new Table();
                    tableLayout  = true;
                    break;

                case RepeatLayout.Flow:
                    outerControl = new WebControl(HtmlTextWriterTag.Span);
                    break;
                }
            }

            bool separators = user.HasSeparators;

            if (outerControl != null)
            {
                // use ClientID (and not ID) since we want to render out the fully qualified client id
                // even though this outer control will not be parented to the control hierarchy
                outerControl.ID = baseControl.ClientID;

                outerControl.CopyBaseAttributes(baseControl);
                outerControl.ApplyStyle(controlStyle);
                outerControl.RenderBeginTag(writer);
            }

            if (user.HasHeader)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    // add attributes to render for TD
                    if (totalColumns != 1)
                    {
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Header, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (tableLayout)
                {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (outerTableImplied == false)
                {
                    writer.WriteFullBeginTag("br");
                }
            }

            int itemCounter = 0;

            for (int currentRow = 0; currentRow < totalRows; currentRow++)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                int itemIndex = currentRow;

                for (int currentCol = 0; currentCol < totalColumns; currentCol++)
                {
                    if (itemCounter >= itemCount)
                    {
                        // done rendering all items, so break out of the loop now...
                        // we might end up here, in unfilled columns attempting to re-render items that
                        // have already been rendered on the next column in a prior row.
                        break;
                    }

                    if (currentCol != 0)
                    {
                        itemIndex += totalRows;

                        // if the previous column (currentColumn - 1) was not a filled column, i.e.,
                        // it had one less item (the maximum possible), then subtract 1 from the item index.
                        if ((currentCol - 1) >= filledColumns)
                        {
                            itemIndex--;
                        }
                    }


                    if (itemIndex >= itemCount)
                    {
                        continue;
                    }

                    itemCounter++;

                    if (tableLayout)
                    {
                        // add style attributes to render for TD
                        Style style = user.GetItemStyle(ListItemType.Item, itemIndex);
                        if (style != null)
                        {
                            style.AddAttributesToRender(writer);
                        }
                        // render begin tag for TD
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                    user.RenderItem(ListItemType.Item, itemIndex, this, writer);
                    if (tableLayout)
                    {
                        // render end tag for TD
                        writer.RenderEndTag();
                    }
                    if (separators && (itemIndex != (itemCount - 1)))
                    {
                        if (totalColumns == 1)
                        {
                            if (tableLayout)
                            {
                                writer.RenderEndTag();
                                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                            }
                            else
                            {
                                writer.WriteFullBeginTag("br");
                            }
                        }

                        if (tableLayout)
                        {
                            Style style = user.GetItemStyle(ListItemType.Separator, itemIndex);
                            if (style != null)
                            {
                                style.AddAttributesToRender(writer);
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        }
                        if (itemIndex < itemCount)
                        {
                            user.RenderItem(ListItemType.Separator, itemIndex, this, writer);
                        }
                        if (tableLayout)
                        {
                            writer.RenderEndTag();
                        }
                    }
                }

                if (tableLayout)
                {
                    writer.RenderEndTag();
                }
                else
                {
                    if (((currentRow != totalRows - 1) || user.HasFooter) &&
                        (outerTableImplied == false))
                    {
                        writer.WriteFullBeginTag("br");
                    }
                }
            }

            if (user.HasFooter)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    // add attributes to render for TD
                    if (totalColumns != 1)
                    {
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (tableLayout)
                {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }

            if (outerControl != null)
            {
                outerControl.RenderEndTag(writer);
            }
        }
		public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
		{
			if(RepeatDirection == RepeatDirection.Vertical)
			{
				DoVerticalRendering(writer, user, controlStyle, baseControl);
			} else
			{
				DoHorizontalRendering(writer, user, controlStyle, baseControl);
			}
		}
Example #19
0
        /// <include file='doc\RepeatInfo.uex' path='docs/doc[@for="RepeatInfo.RenderHorizontalRepeater"]/*' />
        /// <devdoc>
        /// </devdoc>
        private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            Debug.Assert(outerTableImplied == false, "Cannot use outer implied table with Horizontal layout");

            int itemCount = user.RepeatedItemCount;

            int totalColumns  = repeatColumns;
            int currentColumn = 0;

            if (totalColumns == 0)
            {
                // 0 implies a complete horizontal repetition without any
                // column count constraints
                totalColumns = itemCount;
            }

            WebControl outerControl = null;
            bool       tableLayout  = false;

            switch (repeatLayout)
            {
            case RepeatLayout.Table:
                outerControl = new Table();
                tableLayout  = true;
                break;

            case RepeatLayout.Flow:
                outerControl = new WebControl(HtmlTextWriterTag.Span);
                break;
            }

            bool separators = user.HasSeparators;

            // use ClientID (and not ID) since we want to render out the fully qualified client id
            // even though this outer control will not be parented to the control hierarchy
            outerControl.ID = baseControl.ClientID;

            outerControl.CopyBaseAttributes(baseControl);
            outerControl.ApplyStyle(controlStyle);
            outerControl.RenderBeginTag(writer);

            if (user.HasHeader)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    // add attributes to render for TD
                    if ((totalColumns != 1) || separators)
                    {
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Header, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (tableLayout)
                {
                    // render end tag for TD
                    writer.RenderEndTag();

                    // render end tag for TR
                    writer.RenderEndTag();
                }
                else
                {
                    if (totalColumns < itemCount)
                    {
                        // we have multiple rows, so have a break between the header and first row.
                        writer.WriteFullBeginTag("br");
                    }
                }
            }

            for (int i = 0; i < itemCount; i++)
            {
                if (tableLayout && (currentColumn == 0))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                if (tableLayout)
                {
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Item, i);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Item, i, this, writer);
                if (tableLayout)
                {
                    // render end tag for TD
                    writer.RenderEndTag();
                }
                if (separators && (i != (itemCount - 1)))
                {
                    if (tableLayout)
                    {
                        Style style = user.GetItemStyle(ListItemType.Separator, i);
                        if (style != null)
                        {
                            style.AddAttributesToRender(writer);
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                    user.RenderItem(ListItemType.Separator, i, this, writer);
                    if (tableLayout)
                    {
                        writer.RenderEndTag();
                    }
                }

                currentColumn++;
                if ((currentColumn == totalColumns) || (i == itemCount - 1))
                {
                    if (tableLayout)
                    {
                        // End tag for TR
                        writer.RenderEndTag();
                    }
                    else
                    {
                        // write out the <br> after rows when there are multiple rows
                        if (totalColumns < itemCount)
                        {
                            writer.WriteFullBeginTag("br");
                        }
                    }

                    currentColumn = 0;
                }
            }

            if (user.HasFooter)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    if ((totalColumns != 1) || separators)
                    {
                        // add attributes to render for TD
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (tableLayout)
                {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }

            outerControl.RenderEndTag(writer);
        }
        /// <devdoc>
        /// </devdoc>
        private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) {
            int itemCount = user.RepeatedItemCount;
            int totalColumns;
            int totalRows;
            int filledColumns;

            // List Layout Constraint --> Columns = 0 or 1
            if ((repeatColumns == 0) || (repeatColumns == 1)) {
                // A RepeatColumns of 0 implies a completely vertical repetition in
                // a single column. This is same as repeatColumns of 1.
                totalColumns = 1;
                filledColumns = 1;
                totalRows = itemCount;
            }
            else {
                totalColumns = repeatColumns;
                totalRows = (int)((itemCount + repeatColumns - 1) / repeatColumns);

                if ((totalRows == 0) && (itemCount != 0)) {
                    // if repeatColumns is a huge number like Int32.MaxValue, then the
                    // calculation above essentially reduces down to 0
                    totalRows = 1;
                }

                filledColumns = itemCount % totalColumns;
                if (filledColumns == 0) {
                    filledColumns = totalColumns;
                }
            }


            WebControl outerControl = null;
            bool tableLayout = false;

            // List Layout Constraint --> OuterTableImplied = false
            // List Layout Constraint --> tableLayout = false
            if (!outerTableImplied) {
                switch (repeatLayout) {
                    case RepeatLayout.Table:
                        outerControl = new Table();
                        if (Caption.Length != 0) {
                            ((Table)outerControl).Caption = Caption;
                            ((Table)outerControl).CaptionAlign = CaptionAlign;
                        }
                        tableLayout = true;
                        break;
                    case RepeatLayout.Flow:
                        outerControl = new WebControl(HtmlTextWriterTag.Span);
                        break;
                    case RepeatLayout.UnorderedList:
                        outerControl = new WebControl(HtmlTextWriterTag.Ul);
                        break;
                    case RepeatLayout.OrderedList:
                        outerControl = new WebControl(HtmlTextWriterTag.Ol);
                        break;
                }
            }

            bool separators = user.HasSeparators;
            // List Layout Constraint --> separators = false

            if (outerControl != null) {
                // use ClientID (and not ID) since we want to render out the fully qualified client id
                // even though this outer control will not be parented to the control hierarchy
                outerControl.ID = baseControl.ClientID;

                outerControl.CopyBaseAttributes(baseControl);
                outerControl.ApplyStyle(controlStyle);
                outerControl.RenderBeginTag(writer);
            }

            // List Layout Constraint --> HasHeader = false
            if (user.HasHeader) {
                if (tableLayout) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    // add attributes to render for TH
                    if (totalColumns != 1) {
                        int columnSpan = totalColumns;
                        if (separators)
                            columnSpan += totalColumns;
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (useAccessibleHeader) {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }

                    // add style attributes to render for TD/TH
                    Style style = user.GetItemStyle(ListItemType.Header, -1);
                    if (style != null) {
                        style.AddAttributesToRender(writer);
                    }

                    // render begin tag for TD/TH
                    if (useAccessibleHeader) {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (tableLayout) {
                    // render end tags TD/TH and TR
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (!outerTableImplied) {
                    if (EnableLegacyRendering) {
                        writer.WriteObsoleteBreak();
                    }
                    else {
                        writer.WriteBreak();
                    }
                }
            }

            int itemCounter = 0;

            for (int currentRow = 0; currentRow < totalRows; currentRow++) {
                // List Layout Constraint --> tableLayout = false
                if (tableLayout) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                int itemIndex = currentRow;

                for (int currentCol = 0; currentCol < totalColumns; currentCol++) {
                    if (itemCounter >= itemCount) {
                        // done rendering all items, so break out of the loop now...
                        // we might end up here, in unfilled columns attempting to re-render items that
                        // have already been rendered on the next column in a prior row.
                        break;
                    }
                     
                    if (currentCol != 0) {
                        itemIndex += totalRows;
 
                        // if the previous column (currentColumn - 1) was not a filled column, i.e.,
                        // it had one less item (the maximum possible), then subtract 1 from the item index.
                        if ((currentCol - 1) >= filledColumns) {
                            itemIndex--;
                        }
                    }


                    if (itemIndex >= itemCount)
                        continue;

                    itemCounter++;

                    // List Layout Constraint --> tableLayout = false
                    if (tableLayout) {
                        // add style attributes to render for TD
                        Style style = user.GetItemStyle(ListItemType.Item, itemIndex);
                        if (style != null)
                            style.AddAttributesToRender(writer);
                        // render begin tag for TD
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }

                    if (IsListLayout) {
                        writer.RenderBeginTag(HtmlTextWriterTag.Li);
                    }

                    user.RenderItem(ListItemType.Item, itemIndex, this, writer);

                    if (IsListLayout) {
                        writer.RenderEndTag();
                        writer.WriteLine();
                    }

                    // List Layout Constraint --> tableLayout = false
                    if (tableLayout) {
                        // render end tag for TD
                        writer.RenderEndTag();
                    }

                    // List Layout Constraint --> separators = false
                    if (separators) {
                        if (itemIndex != (itemCount - 1)) {
                            if (totalColumns == 1) {
                                if (tableLayout) {
                                    writer.RenderEndTag();
                                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                                }
                                else {
                                    if (!outerTableImplied) {
                                        if (EnableLegacyRendering) {
                                            writer.WriteObsoleteBreak();
                                        }
                                        else {
                                            writer.WriteBreak();
                                        }
                                    }
                                }
                            }
    
                            if (tableLayout) {
                                Style style = user.GetItemStyle(ListItemType.Separator, itemIndex);
                                if (style != null)
                                    style.AddAttributesToRender(writer);
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            }
                            if (itemIndex < itemCount)
                                user.RenderItem(ListItemType.Separator, itemIndex, this, writer);
                            if (tableLayout)
                                writer.RenderEndTag();
                        }
                        else {
                            // if we're on the last filled line and separators are specified, add another <td/>
                            // to accomodate for the lack of a separator on the last item.  If there's only one
                            // column, though, separators will get their own row anyways.
                            if (tableLayout && totalColumns > 1) {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                }
             
                // on the last line, fill in the remaining empty slots with <td/>s.  We need twice as many
                // if there were separators.
                // List Layout Constraint --> tableLayout = false
                if (tableLayout) {
                    if (currentRow == totalRows - 1) {
                        int unfilledColumns = totalColumns - filledColumns;
                        if (separators) {
                            int unfilledColumnsWithSeparators = unfilledColumns * 2;
                            if (unfilledColumnsWithSeparators >= unfilledColumns) {
                                unfilledColumns = unfilledColumnsWithSeparators;
                            }
                        }
                        if (unfilledColumns != 0) {
                            for (int i = 0; i < unfilledColumns; i++) {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                    writer.RenderEndTag();
                }
                else {
                    if (((currentRow != totalRows - 1) || user.HasFooter) &&
                        (!outerTableImplied) && (!IsListLayout)) {

                        if (EnableLegacyRendering) {
                            writer.WriteObsoleteBreak();
                        }
                        else {
                            writer.WriteBreak();
                        }
                    }
                }
            }

            // List Layout Constraint --> HasFooter = false
            if (user.HasFooter) {
                if (tableLayout) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    // add attributes to render for TD
                    if (totalColumns != 1) {
                        int columnSpan = totalColumns;
                        if (separators)
                            columnSpan += totalColumns;
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style != null)
                        style.AddAttributesToRender(writer);
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (tableLayout) {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }

            if (outerControl != null)
                outerControl.RenderEndTag(writer);
        }
        private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int repeatColumns;
            int num3;
            int num4;
            int repeatedItemCount = user.RepeatedItemCount;
            if ((this.repeatColumns == 0) || (this.repeatColumns == 1))
            {
                repeatColumns = 1;
                num4 = 1;
                num3 = repeatedItemCount;
            }
            else
            {
                repeatColumns = this.repeatColumns;
                num3 = ((repeatedItemCount + this.repeatColumns) - 1) / this.repeatColumns;
                if ((num3 == 0) && (repeatedItemCount != 0))
                {
                    num3 = 1;
                }
                num4 = repeatedItemCount % repeatColumns;
                if (num4 == 0)
                {
                    num4 = repeatColumns;
                }
            }
            WebControl control = null;
            bool flag = false;
            if (!this.outerTableImplied)
            {
                switch (this.repeatLayout)
                {
                    case System.Web.UI.WebControls.RepeatLayout.Table:
                        control = new Table();
                        if (this.Caption.Length != 0)
                        {
                            ((Table) control).Caption = this.Caption;
                            ((Table) control).CaptionAlign = this.CaptionAlign;
                        }
                        flag = true;
                        break;

                    case System.Web.UI.WebControls.RepeatLayout.Flow:
                        control = new WebControl(HtmlTextWriterTag.Span);
                        break;

                    case System.Web.UI.WebControls.RepeatLayout.UnorderedList:
                        control = new WebControl(HtmlTextWriterTag.Ul);
                        break;

                    case System.Web.UI.WebControls.RepeatLayout.OrderedList:
                        control = new WebControl(HtmlTextWriterTag.Ol);
                        break;
                }
            }
            bool hasSeparators = user.HasSeparators;
            if (control != null)
            {
                control.ID = baseControl.ClientID;
                control.CopyBaseAttributes(baseControl);
                control.ApplyStyle(controlStyle);
                control.RenderBeginTag(writer);
            }
            if (user.HasHeader)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if (repeatColumns != 1)
                    {
                        int num5 = repeatColumns;
                        if (hasSeparators)
                        {
                            num5 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num5.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }
                    Style itemStyle = user.GetItemStyle(ListItemType.Header, -1);
                    if (itemStyle != null)
                    {
                        itemStyle.AddAttributesToRender(writer);
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (!this.outerTableImplied)
                {
                    if (this.EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }
            int num6 = 0;
            for (int i = 0; i < num3; i++)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }
                int repeatIndex = i;
                for (int j = 0; j < repeatColumns; j++)
                {
                    if (num6 >= repeatedItemCount)
                    {
                        break;
                    }
                    if (j != 0)
                    {
                        repeatIndex += num3;
                        if ((j - 1) >= num4)
                        {
                            repeatIndex--;
                        }
                    }
                    if (repeatIndex < repeatedItemCount)
                    {
                        num6++;
                        if (flag)
                        {
                            Style style2 = user.GetItemStyle(ListItemType.Item, repeatIndex);
                            if (style2 != null)
                            {
                                style2.AddAttributesToRender(writer);
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        }
                        if (this.IsListLayout)
                        {
                            writer.RenderBeginTag(HtmlTextWriterTag.Li);
                        }
                        user.RenderItem(ListItemType.Item, repeatIndex, this, writer);
                        if (this.IsListLayout)
                        {
                            writer.RenderEndTag();
                            writer.WriteLine();
                        }
                        if (flag)
                        {
                            writer.RenderEndTag();
                        }
                        if (hasSeparators)
                        {
                            if (repeatIndex != (repeatedItemCount - 1))
                            {
                                if (repeatColumns == 1)
                                {
                                    if (flag)
                                    {
                                        writer.RenderEndTag();
                                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                                    }
                                    else if (!this.outerTableImplied)
                                    {
                                        if (this.EnableLegacyRendering)
                                        {
                                            writer.WriteObsoleteBreak();
                                        }
                                        else
                                        {
                                            writer.WriteBreak();
                                        }
                                    }
                                }
                                if (flag)
                                {
                                    Style style3 = user.GetItemStyle(ListItemType.Separator, repeatIndex);
                                    if (style3 != null)
                                    {
                                        style3.AddAttributesToRender(writer);
                                    }
                                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                }
                                if (repeatIndex < repeatedItemCount)
                                {
                                    user.RenderItem(ListItemType.Separator, repeatIndex, this, writer);
                                }
                                if (flag)
                                {
                                    writer.RenderEndTag();
                                }
                            }
                            else if (flag && (repeatColumns > 1))
                            {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                }
                if (flag)
                {
                    if (i == (num3 - 1))
                    {
                        int num10 = repeatColumns - num4;
                        if (hasSeparators)
                        {
                            int num11 = num10 * 2;
                            if (num11 >= num10)
                            {
                                num10 = num11;
                            }
                        }
                        if (num10 != 0)
                        {
                            for (int k = 0; k < num10; k++)
                            {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                    writer.RenderEndTag();
                }
                else if (((i != (num3 - 1)) || user.HasFooter) && (!this.outerTableImplied && !this.IsListLayout))
                {
                    if (this.EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }
            if (user.HasFooter)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if (repeatColumns != 1)
                    {
                        int num13 = repeatColumns;
                        if (hasSeparators)
                        {
                            num13 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num13.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    Style style4 = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style4 != null)
                    {
                        style4.AddAttributesToRender(writer);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }
            if (control != null)
            {
                control.RenderEndTag(writer);
            }
        }
Example #22
0
        private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int repeatedItemCount = user.RepeatedItemCount;
            int repeatColumns     = this.repeatColumns;
            int num3 = 0;

            if (repeatColumns == 0)
            {
                repeatColumns = repeatedItemCount;
            }
            WebControl control = null;
            bool       flag    = false;

            switch (this.repeatLayout)
            {
            case System.Web.UI.WebControls.RepeatLayout.Table:
                control = new Table();
                if (this.Caption.Length != 0)
                {
                    ((Table)control).Caption      = this.Caption;
                    ((Table)control).CaptionAlign = this.CaptionAlign;
                }
                flag = true;
                break;

            case System.Web.UI.WebControls.RepeatLayout.Flow:
                control = new WebControl(HtmlTextWriterTag.Span);
                break;
            }
            bool hasSeparators = user.HasSeparators;

            control.ID = baseControl.ClientID;
            control.CopyBaseAttributes(baseControl);
            control.ApplyStyle(controlStyle);
            control.RenderBeginTag(writer);
            if (user.HasHeader)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if ((repeatColumns != 1) || hasSeparators)
                    {
                        int num4 = repeatColumns;
                        if (hasSeparators)
                        {
                            num4 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num4.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }
                    Style itemStyle = user.GetItemStyle(ListItemType.Header, -1);
                    if (itemStyle != null)
                    {
                        itemStyle.AddAttributesToRender(writer);
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (repeatColumns < repeatedItemCount)
                {
                    if (this.EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }
            for (int i = 0; i < repeatedItemCount; i++)
            {
                if (flag && (num3 == 0))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }
                if (flag)
                {
                    Style style2 = user.GetItemStyle(ListItemType.Item, i);
                    if (style2 != null)
                    {
                        style2.AddAttributesToRender(writer);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Item, i, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                }
                if (hasSeparators && (i != (repeatedItemCount - 1)))
                {
                    if (flag)
                    {
                        Style style3 = user.GetItemStyle(ListItemType.Separator, i);
                        if (style3 != null)
                        {
                            style3.AddAttributesToRender(writer);
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                    user.RenderItem(ListItemType.Separator, i, this, writer);
                    if (flag)
                    {
                        writer.RenderEndTag();
                    }
                }
                num3++;
                if (flag && (i == (repeatedItemCount - 1)))
                {
                    int num6 = repeatColumns - num3;
                    if (hasSeparators)
                    {
                        int num7 = (num6 * 2) + 1;
                        if (num7 > num6)
                        {
                            num6 = num7;
                        }
                    }
                    for (int j = 0; j < num6; j++)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.RenderEndTag();
                    }
                }
                if ((num3 == repeatColumns) || (i == (repeatedItemCount - 1)))
                {
                    if (flag)
                    {
                        writer.RenderEndTag();
                    }
                    else if (repeatColumns < repeatedItemCount)
                    {
                        if (this.EnableLegacyRendering)
                        {
                            writer.WriteObsoleteBreak();
                        }
                        else
                        {
                            writer.WriteBreak();
                        }
                    }
                    num3 = 0;
                }
            }
            if (user.HasFooter)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if ((repeatColumns != 1) || hasSeparators)
                    {
                        int num9 = repeatColumns;
                        if (hasSeparators)
                        {
                            num9 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num9.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    Style style4 = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style4 != null)
                    {
                        style4.AddAttributesToRender(writer);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }
            control.RenderEndTag(writer);
        }
Example #23
0
		public void CheckIRepeatInfoUser (IRepeatInfoUser riu)
		{
			Assert.IsFalse (riu.HasFooter, "HasFooter");
			Assert.IsFalse (riu.HasHeader, "HasHeader");
			Assert.IsFalse (riu.HasSeparators, "HasSeparators");
			Assert.AreEqual (0, riu.RepeatedItemCount, "RepeatedItemCount");
		}
Example #24
0
        /// <devdoc>
        /// </devdoc>
        private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            Debug.Assert(outerTableImplied == false, "Cannot use outer implied table with Horizontal layout");

            int itemCount = user.RepeatedItemCount;

            int totalColumns  = repeatColumns;
            int currentColumn = 0;

            if (totalColumns == 0)
            {
                // 0 implies a complete horizontal repetition without any
                // column count constraints
                totalColumns = itemCount;
            }

            WebControl outerControl = null;
            bool       tableLayout  = false;

            switch (repeatLayout)
            {
            case RepeatLayout.Table:
                outerControl = new Table();
                if (Caption.Length != 0)
                {
                    ((Table)outerControl).Caption      = Caption;
                    ((Table)outerControl).CaptionAlign = CaptionAlign;
                }
                tableLayout = true;
                break;

            case RepeatLayout.Flow:
                outerControl = new WebControl(HtmlTextWriterTag.Span);
                break;
            }

            bool separators = user.HasSeparators;

            // use ClientID (and not ID) since we want to render out the fully qualified client id
            // even though this outer control will not be parented to the control hierarchy
            outerControl.ID = baseControl.ClientID;

            outerControl.CopyBaseAttributes(baseControl);
            outerControl.ApplyStyle(controlStyle);
            outerControl.RenderBeginTag(writer);

            if (user.HasHeader)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    // add attributes to render for TD/TH
                    if ((totalColumns != 1) || separators)
                    {
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (useAccessibleHeader)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }

                    // add style attributes to render for TD/TH
                    Style style = user.GetItemStyle(ListItemType.Header, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }

                    // render begin tag
                    if (useAccessibleHeader)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (tableLayout)
                {
                    // render end tags TD/TH and TR
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else
                {
                    if (totalColumns < itemCount)
                    {
                        // we have multiple rows, so have a break between the header and first row.
                        if (EnableLegacyRendering)
                        {
                            writer.WriteObsoleteBreak();
                        }
                        else
                        {
                            writer.WriteBreak();
                        }
                    }
                }
            }

            for (int i = 0; i < itemCount; i++)
            {
                if (tableLayout && (currentColumn == 0))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                if (tableLayout)
                {
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Item, i);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Item, i, this, writer);
                if (tableLayout)
                {
                    // render end tag for TD
                    writer.RenderEndTag();
                }
                if (separators && (i != (itemCount - 1)))
                {
                    if (tableLayout)
                    {
                        Style style = user.GetItemStyle(ListItemType.Separator, i);
                        if (style != null)
                        {
                            style.AddAttributesToRender(writer);
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                    user.RenderItem(ListItemType.Separator, i, this, writer);
                    if (tableLayout)
                    {
                        writer.RenderEndTag();
                    }
                }

                currentColumn++;

                // on the last line, fill in the rest of the empty spots with <td/>s.
                // If there were separators, we need twice as many plus one to accomodate for
                // the last item not having a separator after it.
                if (tableLayout && i == itemCount - 1)
                {
                    int unfilledColumns = totalColumns - currentColumn;
                    if (separators == true)
                    {
                        int unfilledColumnsWithSeparators = (unfilledColumns * 2) + 1;
                        if (unfilledColumnsWithSeparators > unfilledColumns)
                        {
                            unfilledColumns = unfilledColumnsWithSeparators;
                        }
                    }
                    for (int k = 0; k < unfilledColumns; k++)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.RenderEndTag();
                    }
                }

                if ((currentColumn == totalColumns) || (i == itemCount - 1))
                {
                    if (tableLayout)
                    {
                        // End tag for TR
                        writer.RenderEndTag();
                    }
                    else
                    {
                        // write out the <br> after rows when there are multiple rows
                        if (totalColumns < itemCount)
                        {
                            if (EnableLegacyRendering)
                            {
                                writer.WriteObsoleteBreak();
                            }
                            else
                            {
                                writer.WriteBreak();
                            }
                        }
                    }

                    currentColumn = 0;
                }
            }

            if (user.HasFooter)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    if ((totalColumns != 1) || separators)
                    {
                        // add attributes to render for TD
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (tableLayout)
                {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }

            outerControl.RenderEndTag(writer);
        }
 public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
 {
     if (this.IsListLayout)
     {
         if ((user.HasFooter || user.HasHeader) || user.HasSeparators)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutDoesNotSupportHeaderFooterSeparator"));
         }
         if (this.RepeatDirection != System.Web.UI.WebControls.RepeatDirection.Vertical)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutOnlySupportsVerticalLayout"));
         }
         if ((this.RepeatColumns != 0) && (this.RepeatColumns != 1))
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutDoesNotSupportMultipleColumn"));
         }
         if (this.OuterTableImplied)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("RepeatInfo_ListLayoutDoesNotSupportImpliedOuterTable"));
         }
     }
     if (this.repeatDirection == System.Web.UI.WebControls.RepeatDirection.Vertical)
     {
         this.RenderVerticalRepeater(writer, user, controlStyle, baseControl);
     }
     else
     {
         this.RenderHorizontalRepeater(writer, user, controlStyle, baseControl);
     }
 }
        /// <devdoc>
        /// </devdoc>
        private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) {
            Debug.Assert(outerTableImplied == false, "Cannot use outer implied table with Horizontal layout");

            int itemCount = user.RepeatedItemCount;

            int totalColumns = repeatColumns;
            int currentColumn = 0;

            if (totalColumns == 0) {
                // 0 implies a complete horizontal repetition without any
                // column count constraints
                totalColumns = itemCount;
            }

            WebControl outerControl = null;
            bool tableLayout = false;

            switch (repeatLayout) {
                case RepeatLayout.Table:
                    outerControl = new Table();
                    if (Caption.Length != 0) {
                        ((Table)outerControl).Caption = Caption;
                        ((Table)outerControl).CaptionAlign = CaptionAlign;
                    }
                    tableLayout = true;
                    break;
                case RepeatLayout.Flow:
                    outerControl = new WebControl(HtmlTextWriterTag.Span);
                    break;
            }

            bool separators = user.HasSeparators;

            // use ClientID (and not ID) since we want to render out the fully qualified client id
            // even though this outer control will not be parented to the control hierarchy
            outerControl.ID = baseControl.ClientID;

            outerControl.CopyBaseAttributes(baseControl);
            outerControl.ApplyStyle(controlStyle);
            outerControl.RenderBeginTag(writer);

            if (user.HasHeader) {
                if (tableLayout) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    // add attributes to render for TD/TH
                    if ((totalColumns != 1) || separators) {
                        int columnSpan = totalColumns;
                        if (separators)
                            columnSpan += totalColumns;
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (useAccessibleHeader) {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }

                    // add style attributes to render for TD/TH
                    Style style = user.GetItemStyle(ListItemType.Header, -1);
                    if (style != null) {
                        style.AddAttributesToRender(writer);
                    }

                    // render begin tag
                    if (useAccessibleHeader) {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (tableLayout) {
                    // render end tags TD/TH and TR
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else {
                    if (totalColumns < itemCount) {
                        // we have multiple rows, so have a break between the header and first row.
                        if (EnableLegacyRendering) {
                            writer.WriteObsoleteBreak();
                        }
                        else {
                            writer.WriteBreak();
                        }
                    }
                }
            }

            for (int i = 0; i < itemCount; i++) {
                if (tableLayout && (currentColumn == 0)) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                if (tableLayout) {
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Item, i);
                    if (style != null)
                        style.AddAttributesToRender(writer);
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Item, i, this, writer);
                if (tableLayout) {
                    // render end tag for TD
                    writer.RenderEndTag();
                }
                if (separators && (i != (itemCount - 1))) {
                    if (tableLayout) {
                        Style style = user.GetItemStyle(ListItemType.Separator, i);
                        if (style != null)
                            style.AddAttributesToRender(writer);
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                    user.RenderItem(ListItemType.Separator, i, this, writer);
                    if (tableLayout)
                        writer.RenderEndTag();
                }

                currentColumn++;
                
                // on the last line, fill in the rest of the empty spots with <td/>s.
                // If there were separators, we need twice as many plus one to accomodate for
                // the last item not having a separator after it.
                if (tableLayout && i == itemCount - 1) {
                    int unfilledColumns = totalColumns - currentColumn;
                    if (separators == true) {
                        int unfilledColumnsWithSeparators = (unfilledColumns * 2) + 1;
                        if (unfilledColumnsWithSeparators > unfilledColumns) {
                            unfilledColumns = unfilledColumnsWithSeparators;
                        }
                    }
                    for (int k = 0; k < unfilledColumns; k++) {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.RenderEndTag();
                    }
                }
                
                if ((currentColumn == totalColumns) || (i == itemCount - 1)) {
                    if (tableLayout) {
                        // End tag for TR
                        writer.RenderEndTag();
                    }
                    else {
                        // write out the <br> after rows when there are multiple rows
                        if (totalColumns < itemCount) {
                            if (EnableLegacyRendering) {
                                writer.WriteObsoleteBreak();
                            }
                            else {
                                writer.WriteBreak();
                            }
                        }
                    }

                    currentColumn = 0;
                }
            }

            if (user.HasFooter) {
                if (tableLayout) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    if ((totalColumns != 1) || separators) {
                        // add attributes to render for TD
                        int columnSpan = totalColumns;
                        if (separators)
                            columnSpan += totalColumns;
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style != null)
                        style.AddAttributesToRender(writer);
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (tableLayout) {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }

            outerControl.RenderEndTag(writer);
        }
 // Methods
 public void RenderRepeater(System.Web.UI.HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
 {
 }
Example #28
0
        private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int repeatColumns;
            int num3;
            int num4;
            int repeatedItemCount = user.RepeatedItemCount;

            if ((this.repeatColumns == 0) || (this.repeatColumns == 1))
            {
                repeatColumns = 1;
                num4          = 1;
                num3          = repeatedItemCount;
            }
            else
            {
                repeatColumns = this.repeatColumns;
                num3          = ((repeatedItemCount + this.repeatColumns) - 1) / this.repeatColumns;
                if ((num3 == 0) && (repeatedItemCount != 0))
                {
                    num3 = 1;
                }
                num4 = repeatedItemCount % repeatColumns;
                if (num4 == 0)
                {
                    num4 = repeatColumns;
                }
            }
            WebControl control = null;
            bool       flag    = false;

            if (!this.outerTableImplied)
            {
                switch (this.repeatLayout)
                {
                case System.Web.UI.WebControls.RepeatLayout.Table:
                    control = new Table();
                    if (this.Caption.Length != 0)
                    {
                        ((Table)control).Caption      = this.Caption;
                        ((Table)control).CaptionAlign = this.CaptionAlign;
                    }
                    flag = true;
                    break;

                case System.Web.UI.WebControls.RepeatLayout.Flow:
                    control = new WebControl(HtmlTextWriterTag.Span);
                    break;

                case System.Web.UI.WebControls.RepeatLayout.UnorderedList:
                    control = new WebControl(HtmlTextWriterTag.Ul);
                    break;

                case System.Web.UI.WebControls.RepeatLayout.OrderedList:
                    control = new WebControl(HtmlTextWriterTag.Ol);
                    break;
                }
            }
            bool hasSeparators = user.HasSeparators;

            if (control != null)
            {
                control.ID = baseControl.ClientID;
                control.CopyBaseAttributes(baseControl);
                control.ApplyStyle(controlStyle);
                control.RenderBeginTag(writer);
            }
            if (user.HasHeader)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if (repeatColumns != 1)
                    {
                        int num5 = repeatColumns;
                        if (hasSeparators)
                        {
                            num5 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num5.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }
                    Style itemStyle = user.GetItemStyle(ListItemType.Header, -1);
                    if (itemStyle != null)
                    {
                        itemStyle.AddAttributesToRender(writer);
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (!this.outerTableImplied)
                {
                    if (this.EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }
            int num6 = 0;

            for (int i = 0; i < num3; i++)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }
                int repeatIndex = i;
                for (int j = 0; j < repeatColumns; j++)
                {
                    if (num6 >= repeatedItemCount)
                    {
                        break;
                    }
                    if (j != 0)
                    {
                        repeatIndex += num3;
                        if ((j - 1) >= num4)
                        {
                            repeatIndex--;
                        }
                    }
                    if (repeatIndex < repeatedItemCount)
                    {
                        num6++;
                        if (flag)
                        {
                            Style style2 = user.GetItemStyle(ListItemType.Item, repeatIndex);
                            if (style2 != null)
                            {
                                style2.AddAttributesToRender(writer);
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        }
                        if (this.IsListLayout)
                        {
                            writer.RenderBeginTag(HtmlTextWriterTag.Li);
                        }
                        user.RenderItem(ListItemType.Item, repeatIndex, this, writer);
                        if (this.IsListLayout)
                        {
                            writer.RenderEndTag();
                            writer.WriteLine();
                        }
                        if (flag)
                        {
                            writer.RenderEndTag();
                        }
                        if (hasSeparators)
                        {
                            if (repeatIndex != (repeatedItemCount - 1))
                            {
                                if (repeatColumns == 1)
                                {
                                    if (flag)
                                    {
                                        writer.RenderEndTag();
                                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                                    }
                                    else if (!this.outerTableImplied)
                                    {
                                        if (this.EnableLegacyRendering)
                                        {
                                            writer.WriteObsoleteBreak();
                                        }
                                        else
                                        {
                                            writer.WriteBreak();
                                        }
                                    }
                                }
                                if (flag)
                                {
                                    Style style3 = user.GetItemStyle(ListItemType.Separator, repeatIndex);
                                    if (style3 != null)
                                    {
                                        style3.AddAttributesToRender(writer);
                                    }
                                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                }
                                if (repeatIndex < repeatedItemCount)
                                {
                                    user.RenderItem(ListItemType.Separator, repeatIndex, this, writer);
                                }
                                if (flag)
                                {
                                    writer.RenderEndTag();
                                }
                            }
                            else if (flag && (repeatColumns > 1))
                            {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                }
                if (flag)
                {
                    if (i == (num3 - 1))
                    {
                        int num10 = repeatColumns - num4;
                        if (hasSeparators)
                        {
                            int num11 = num10 * 2;
                            if (num11 >= num10)
                            {
                                num10 = num11;
                            }
                        }
                        if (num10 != 0)
                        {
                            for (int k = 0; k < num10; k++)
                            {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                    writer.RenderEndTag();
                }
                else if (((i != (num3 - 1)) || user.HasFooter) && (!this.outerTableImplied && !this.IsListLayout))
                {
                    if (this.EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }
            if (user.HasFooter)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if (repeatColumns != 1)
                    {
                        int num13 = repeatColumns;
                        if (hasSeparators)
                        {
                            num13 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num13.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    Style style4 = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style4 != null)
                    {
                        style4.AddAttributesToRender(writer);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }
            if (control != null)
            {
                control.RenderEndTag(writer);
            }
        }
Example #29
0
        /// <devdoc>
        /// </devdoc>
        private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int itemCount = user.RepeatedItemCount;
            int totalColumns;
            int totalRows;
            int filledColumns;

            // List Layout Constraint --> Columns = 0 or 1
            if ((repeatColumns == 0) || (repeatColumns == 1))
            {
                // A RepeatColumns of 0 implies a completely vertical repetition in
                // a single column. This is same as repeatColumns of 1.
                totalColumns  = 1;
                filledColumns = 1;
                totalRows     = itemCount;
            }
            else
            {
                totalColumns = repeatColumns;
                totalRows    = (int)((itemCount + repeatColumns - 1) / repeatColumns);

                if ((totalRows == 0) && (itemCount != 0))
                {
                    // if repeatColumns is a huge number like Int32.MaxValue, then the
                    // calculation above essentially reduces down to 0
                    totalRows = 1;
                }

                filledColumns = itemCount % totalColumns;
                if (filledColumns == 0)
                {
                    filledColumns = totalColumns;
                }
            }


            WebControl outerControl = null;
            bool       tableLayout  = false;

            // List Layout Constraint --> OuterTableImplied = false
            // List Layout Constraint --> tableLayout = false
            if (!outerTableImplied)
            {
                switch (repeatLayout)
                {
                case RepeatLayout.Table:
                    outerControl = new Table();
                    if (Caption.Length != 0)
                    {
                        ((Table)outerControl).Caption      = Caption;
                        ((Table)outerControl).CaptionAlign = CaptionAlign;
                    }
                    tableLayout = true;
                    break;

                case RepeatLayout.Flow:
                    outerControl = new WebControl(HtmlTextWriterTag.Span);
                    break;

                case RepeatLayout.UnorderedList:
                    outerControl = new WebControl(HtmlTextWriterTag.Ul);
                    break;

                case RepeatLayout.OrderedList:
                    outerControl = new WebControl(HtmlTextWriterTag.Ol);
                    break;
                }
            }

            bool separators = user.HasSeparators;

            // List Layout Constraint --> separators = false

            if (outerControl != null)
            {
                // use ClientID (and not ID) since we want to render out the fully qualified client id
                // even though this outer control will not be parented to the control hierarchy
                outerControl.ID = baseControl.ClientID;

                outerControl.CopyBaseAttributes(baseControl);
                outerControl.ApplyStyle(controlStyle);
                outerControl.RenderBeginTag(writer);
            }

            // List Layout Constraint --> HasHeader = false
            if (user.HasHeader)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    // add attributes to render for TH
                    if (totalColumns != 1)
                    {
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (useAccessibleHeader)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }

                    // add style attributes to render for TD/TH
                    Style style = user.GetItemStyle(ListItemType.Header, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }

                    // render begin tag for TD/TH
                    if (useAccessibleHeader)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (tableLayout)
                {
                    // render end tags TD/TH and TR
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (!outerTableImplied)
                {
                    if (EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }

            int itemCounter = 0;

            for (int currentRow = 0; currentRow < totalRows; currentRow++)
            {
                // List Layout Constraint --> tableLayout = false
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }

                int itemIndex = currentRow;

                for (int currentCol = 0; currentCol < totalColumns; currentCol++)
                {
                    if (itemCounter >= itemCount)
                    {
                        // done rendering all items, so break out of the loop now...
                        // we might end up here, in unfilled columns attempting to re-render items that
                        // have already been rendered on the next column in a prior row.
                        break;
                    }

                    if (currentCol != 0)
                    {
                        itemIndex += totalRows;

                        // if the previous column (currentColumn - 1) was not a filled column, i.e.,
                        // it had one less item (the maximum possible), then subtract 1 from the item index.
                        if ((currentCol - 1) >= filledColumns)
                        {
                            itemIndex--;
                        }
                    }


                    if (itemIndex >= itemCount)
                    {
                        continue;
                    }

                    itemCounter++;

                    // List Layout Constraint --> tableLayout = false
                    if (tableLayout)
                    {
                        // add style attributes to render for TD
                        Style style = user.GetItemStyle(ListItemType.Item, itemIndex);
                        if (style != null)
                        {
                            style.AddAttributesToRender(writer);
                        }
                        // render begin tag for TD
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }

                    if (IsListLayout)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Li);
                    }

                    user.RenderItem(ListItemType.Item, itemIndex, this, writer);

                    if (IsListLayout)
                    {
                        writer.RenderEndTag();
                        writer.WriteLine();
                    }

                    // List Layout Constraint --> tableLayout = false
                    if (tableLayout)
                    {
                        // render end tag for TD
                        writer.RenderEndTag();
                    }

                    // List Layout Constraint --> separators = false
                    if (separators)
                    {
                        if (itemIndex != (itemCount - 1))
                        {
                            if (totalColumns == 1)
                            {
                                if (tableLayout)
                                {
                                    writer.RenderEndTag();
                                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                                }
                                else
                                {
                                    if (!outerTableImplied)
                                    {
                                        if (EnableLegacyRendering)
                                        {
                                            writer.WriteObsoleteBreak();
                                        }
                                        else
                                        {
                                            writer.WriteBreak();
                                        }
                                    }
                                }
                            }

                            if (tableLayout)
                            {
                                Style style = user.GetItemStyle(ListItemType.Separator, itemIndex);
                                if (style != null)
                                {
                                    style.AddAttributesToRender(writer);
                                }
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            }
                            if (itemIndex < itemCount)
                            {
                                user.RenderItem(ListItemType.Separator, itemIndex, this, writer);
                            }
                            if (tableLayout)
                            {
                                writer.RenderEndTag();
                            }
                        }
                        else
                        {
                            // if we're on the last filled line and separators are specified, add another <td/>
                            // to accomodate for the lack of a separator on the last item.  If there's only one
                            // column, though, separators will get their own row anyways.
                            if (tableLayout && totalColumns > 1)
                            {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                }

                // on the last line, fill in the remaining empty slots with <td/>s.  We need twice as many
                // if there were separators.
                // List Layout Constraint --> tableLayout = false
                if (tableLayout)
                {
                    if (currentRow == totalRows - 1)
                    {
                        int unfilledColumns = totalColumns - filledColumns;
                        if (separators)
                        {
                            int unfilledColumnsWithSeparators = unfilledColumns * 2;
                            if (unfilledColumnsWithSeparators >= unfilledColumns)
                            {
                                unfilledColumns = unfilledColumnsWithSeparators;
                            }
                        }
                        if (unfilledColumns != 0)
                        {
                            for (int i = 0; i < unfilledColumns; i++)
                            {
                                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                writer.RenderEndTag();
                            }
                        }
                    }
                    writer.RenderEndTag();
                }
                else
                {
                    if (((currentRow != totalRows - 1) || user.HasFooter) &&
                        (!outerTableImplied) && (!IsListLayout))
                    {
                        if (EnableLegacyRendering)
                        {
                            writer.WriteObsoleteBreak();
                        }
                        else
                        {
                            writer.WriteBreak();
                        }
                    }
                }
            }

            // List Layout Constraint --> HasFooter = false
            if (user.HasFooter)
            {
                if (tableLayout)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    // add attributes to render for TD
                    if (totalColumns != 1)
                    {
                        int columnSpan = totalColumns;
                        if (separators)
                        {
                            columnSpan += totalColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    // add style attributes to render for TD
                    Style style = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style != null)
                    {
                        style.AddAttributesToRender(writer);
                    }
                    // render begin tag for TD
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (tableLayout)
                {
                    // render end tag for TR and TD
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }

            if (outerControl != null)
            {
                outerControl.RenderEndTag(writer);
            }
        }
		private void DoHorizontalRendering (HtmlTextWriter writer,
						    IRepeatInfoUser user,
						    Style controlStyle,
						    WebControl baseControl)
		{
			/* Based on DoVerticalRendering */
			int total = user.RepeatedItemCount;
			int colsCount = 0;
			int rowsCount = 0;
			WebControl ctrl = null;
			bool isTable = true;
			bool hasSeps = user.HasSeparators;
			if (!outerTableImp){
				isTable = (RepeatLayout == RepeatLayout.Table);
				ctrl = (isTable) ? new Table () : new WebControl (HtmlTextWriterTag.Span);
				ctrl.ID = baseControl.ClientID;
				ctrl.CopyBaseAttributes (baseControl);
				ctrl.ApplyStyle (controlStyle);
				ctrl.RenderBeginTag (writer);
			}

			Style itemStyle;
			int colSpan = 0;
			if (user.HasHeader){
				if (isTable){
					writer.RenderBeginTag (HtmlTextWriterTag.Tr);
					if (colsCount != 1){
						colSpan = colsCount;
						if (hasSeps)
							colSpan += colsCount;
						writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
						     colSpan.ToString (NumberFormatInfo.InvariantInfo));
					}
					itemStyle = user.GetItemStyle (ListItemType.Header, -1);
					if (itemStyle != null)
						itemStyle.AddAttributesToRender (writer);
					writer.RenderBeginTag (HtmlTextWriterTag.Td);
				}

				user.RenderItem (ListItemType.Header, -1, this, writer);
				
				if (isTable){
					writer.RenderEndTag();
					writer.RenderEndTag();
				} else if (repeatColumns < user.RepeatedItemCount)
						writer.WriteFullBeginTag ("br");
			}

			for (int index = 0; index < total; index++){
				if (isTable && index == 0)
					writer.RenderBeginTag (HtmlTextWriterTag.Tr);

				if (isTable){
					itemStyle = user.GetItemStyle (ListItemType.Item, index);
					if (itemStyle != null)
						itemStyle.AddAttributesToRender(writer);
					writer.RenderBeginTag(HtmlTextWriterTag.Td);
				}

				user.RenderItem(ListItemType.Item, index, this, writer);
				if (isTable)
					writer.RenderEndTag ();

				if (hasSeps && index != (total - 1)){
					if (isTable){
						itemStyle = user.GetItemStyle (ListItemType.Separator, index);
						if (itemStyle != null)
							itemStyle.AddAttributesToRender (writer);
						writer.RenderBeginTag (HtmlTextWriterTag.Td);
					}
					user.RenderItem (ListItemType.Separator, index, this, writer);
					if (isTable)
						writer.RenderEndTag ();
				}

				colsCount++;
				if (colsCount == repeatColumns) {
					if (isTable) {
						writer.RenderEndTag ();
						writer.RenderBeginTag (HtmlTextWriterTag.Tr);
					}
					else if (rowsCount < total)
						writer.WriteFullBeginTag ("br");
					colsCount = 0;
				}

				if (index == (total - 1)) {
					if (isTable)
						writer.RenderEndTag ();
					else if (rowsCount < total)
						writer.WriteFullBeginTag ("br");
				}
			}

			if (user.HasFooter){
				if (isTable){
					writer.RenderBeginTag (HtmlTextWriterTag.Tr);
					if (colsCount != 1)
						writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
							colSpan.ToString(NumberFormatInfo.InvariantInfo));

					itemStyle = user.GetItemStyle (ListItemType.Footer, -1);
					if(itemStyle != null)
						itemStyle.AddAttributesToRender (writer);
					writer.RenderBeginTag (HtmlTextWriterTag.Td);
				}
				user.RenderItem (ListItemType.Footer, -1, this, writer);
				if (isTable){
					writer.RenderEndTag ();
					writer.RenderEndTag ();
				}
			}

			if (ctrl != null)
				ctrl.RenderEndTag(writer);
		}
Example #31
0
 // Methods
 public void RenderRepeater(System.Web.UI.HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
 {
 }
		private void DoVerticalRendering(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
		{
			int total = user.RepeatedItemCount;
			int colsCount;
			int rowsCount;
			if(repeatColumns == 0 || repeatColumns==1)
			{
				colsCount = 1;
				rowsCount = total;
			} else
			{
				colsCount = repeatColumns;
				rowsCount = (total + repeatColumns - 1) / repeatColumns;
				if(rowsCount ==0 && total != 0)
				{
					rowsCount = 1;
					colsCount = total;
				}
			}
			WebControl ctrl = null;
			bool isTable = false;
			bool hasSeps = user.HasSeparators;
			if(!outerTableImp)
			{
				if(RepeatLayout == RepeatLayout.Table)
				{
					ctrl = new Table();
					isTable = true;
				} else
				{
					ctrl = new WebControl(HtmlTextWriterTag.Span);
				}
			}

			if(ctrl != null)
			{
				ctrl.ID = baseControl.ClientID;
				ctrl.CopyBaseAttributes(baseControl);
				ctrl.ApplyStyle(controlStyle);
				ctrl.RenderBeginTag(writer);
			}

			Style itemStyle;
			int colSpan = 0;
			if(user.HasHeader)
			{
				if(isTable)
				{
					writer.RenderBeginTag(HtmlTextWriterTag.Tr);
					if(colsCount != 1)
					{
						colSpan = colsCount;
						if(hasSeps)
							colSpan += colsCount;
						writer.AddAttribute(HtmlTextWriterAttribute.Colspan, colSpan.ToString(NumberFormatInfo.InvariantInfo));
					}
					itemStyle = user.GetItemStyle(ListItemType.Header, -1);
					if(itemStyle != null)
					{
						itemStyle.AddAttributesToRender(writer);
					}
					writer.RenderBeginTag(HtmlTextWriterTag.Td);
				}
				user.RenderItem(ListItemType.Header, -1, this, writer);
				if(isTable)
				{
					writer.RenderEndTag();
					writer.RenderEndTag();
				} else
				{
					if(!outerTableImp)
					{
						writer.WriteFullBeginTag("br");
					}
				}
			}

			int rowIndex = 0;
			int colIndex = 0;
			int index = 0;
			int diff = colsCount - (rowsCount*colsCount - total);
			
			while(rowIndex < rowsCount)
			{
				if(isTable)
					writer.RenderBeginTag(HtmlTextWriterTag.Tr);
				colIndex = 0;
				while(colIndex < colsCount)
				{
					if (rowIndex == rowsCount-1 && colIndex >= diff)
						break;
					
					if (colIndex < diff)
						index = rowIndex + colIndex * rowsCount;
					else
						index = rowIndex + colIndex * (rowsCount-1) + diff;

					if(index < total)
					{
						if(isTable)
						{
							itemStyle = user.GetItemStyle(ListItemType.Item, index);
							if(itemStyle != null)
							{
								itemStyle.AddAttributesToRender(writer);
							}
							writer.RenderBeginTag(HtmlTextWriterTag.Td);
						}
						user.RenderItem(ListItemType.Item, index, this, writer);
						if(isTable)
							writer.RenderEndTag();
						if(hasSeps && index != (total - 1))
						{
							if(isTable && colsCount == 1)
							{
								writer.RenderEndTag();
								writer.RenderBeginTag(HtmlTextWriterTag.Tr);
							} else
							{
								writer.WriteFullBeginTag("br");
							}
							if(isTable)
							{
								itemStyle = user.GetItemStyle(ListItemType.Separator, index);
								if(itemStyle != null)
									itemStyle.AddAttributesToRender(writer);
								writer.RenderBeginTag(HtmlTextWriterTag.Td);
							}
							user.RenderItem(ListItemType.Separator, index, this, writer);
							if(isTable)
								writer.RenderEndTag();
						}
					}
					colIndex++;
				}
				if(isTable)
					writer.RenderEndTag();
				else
					if((rowIndex != (rowsCount - 1) || user.HasFooter) && !outerTableImp)
						writer.WriteFullBeginTag("br");
				rowIndex++;
			}
			if(user.HasFooter)
			{
				if(isTable)
				{
					writer.RenderBeginTag(HtmlTextWriterTag.Tr);
					if(colsCount != 1)
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Colspan, colSpan.ToString(NumberFormatInfo.InvariantInfo));
					}
					itemStyle = user.GetItemStyle(ListItemType.Footer, -1);
					if(itemStyle != null)
					{
						itemStyle.AddAttributesToRender(writer);
					}
					writer.RenderBeginTag(HtmlTextWriterTag.Td);
				}
				user.RenderItem(ListItemType.Footer, -1, this, writer);
				if(isTable)
				{
					writer.RenderEndTag();
					writer.RenderEndTag();
				}
			}
			if(ctrl != null)
			{
				ctrl.RenderEndTag(writer);
			}
		}
Example #33
0
		internal void PrintValues (IRepeatInfoUser riu)
		{
			string s = String.Format ("Layout {0}; Direction {1}; Cols {2}; OuterTableImplied {3}\n" +
					"User: itms {4}, hdr {5}; ftr {6}; sep {7}", RepeatLayout, RepeatDirection,
					RepeatColumns, OuterTableImplied, riu.RepeatedItemCount, riu.HasSeparators, riu.HasHeader,
					riu.HasFooter, riu.HasSeparators
				);
			Console.WriteLine (s);
			if (HttpContext.Current != null)
				HttpContext.Current.Trace.Write (s);
		}
        /// <devdoc>
        ///    <para>Renders the Repeater with the specified
        ///       information.</para>
        /// </devdoc>
        public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) {
            if (IsListLayout) {
                if (user.HasFooter || user.HasHeader || user.HasSeparators) {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutDoesNotSupportHeaderFooterSeparator));
                }
                if (RepeatDirection != RepeatDirection.Vertical) {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutOnlySupportsVerticalLayout));
                }
                if ((RepeatColumns != 0) && (RepeatColumns != 1)) {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutDoesNotSupportMultipleColumn));
                }
                if (OuterTableImplied) {
                    throw new InvalidOperationException(SR.GetString(SR.RepeatInfo_ListLayoutDoesNotSupportImpliedOuterTable));
                }
            }

            if (repeatDirection == RepeatDirection.Vertical) {
                RenderVerticalRepeater(writer, user, controlStyle, baseControl);
            }
            else {
                RenderHorizontalRepeater(writer, user, controlStyle, baseControl);
            }
        }
Example #35
0
		void RenderVert (HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) 
		{
			int itms = user.RepeatedItemCount;
			// total number of rows/columns in our table
			int cols = RepeatColumns == 0 ? 1 : RepeatColumns;
			// this gets ceil (itms / cols)
			int rows = (itms + cols - 1) / cols;
			bool sep = user.HasSeparators;
			bool oti = OuterTableImplied;
			int hdr_span = cols * ((sep && cols != 1) ? 2 : 1);
			bool table = RepeatLayout == RepeatLayout.Table && !oti;
			bool show_empty_trailing_items = true;
			bool show_empty_trailing_sep = true;
			
			if (! oti)
				RenderBeginTag (w, controlStyle, baseControl);

			if (Caption.Length > 0) {
				if (CaptionAlign != TableCaptionAlign.NotSet)
					w.AddAttribute (HtmlTextWriterAttribute.Align, CaptionAlign.ToString());

				w.RenderBeginTag (HtmlTextWriterTag.Caption);
				w.Write (Caption);
				w.RenderEndTag ();

			}

			// Render the header
			if (user.HasHeader) {
				if (oti)
					user.RenderItem (ListItemType.Header, -1, this, w);
				else if (table) {
					w.RenderBeginTag (HtmlTextWriterTag.Tr);
					// Make sure the header takes up the full width. We have two
					// columns per item if we are using separators, otherwise
					// one per item.
					if (hdr_span != 1)
						w.AddAttribute (HtmlTextWriterAttribute.Colspan, hdr_span.ToString (), false);

					if (UseAccessibleHeader)
						w.AddAttribute ("scope", "col", false);
					
					Style s = user.GetItemStyle (ListItemType.Header, -1);
					if (s != null)
						s.AddAttributesToRender (w);

					if (UseAccessibleHeader)
						w.RenderBeginTag (HtmlTextWriterTag.Th);
					else
						w.RenderBeginTag (HtmlTextWriterTag.Td);

					user.RenderItem (ListItemType.Header, -1, this, w);
					w.RenderEndTag (); // td
					w.RenderEndTag (); // tr
				} else {
					user.RenderItem (ListItemType.Header, -1, this, w);
					RenderBr (w);
				}
			}

			for (int r = 0; r < rows; r ++) {
				if (table)
					w.RenderBeginTag (HtmlTextWriterTag.Tr);
				
				for (int c = 0; c < cols; c ++) {
					// Find the item number we are in according to the repeat
					// direction.
					int item = index_vert (rows, cols, r, c, itms);

					// This item is blank because there there not enough items
					// to make a full row.
					if (!show_empty_trailing_items && item >= itms)
						continue;

					if (table) {
						Style s = null;
						if (item < itms)
							s = user.GetItemStyle (ListItemType.Item, item);
						if (s != null)
							s.AddAttributesToRender (w);
						w.RenderBeginTag (HtmlTextWriterTag.Td);
					}
					
					if (item < itms)
						user.RenderItem (ListItemType.Item, item, this, w);

					if (table)
						w.RenderEndTag (); // td

					if (sep && cols != 1) {
						if (table) {
							if (item < itms - 1) {
								Style s = user.GetItemStyle (ListItemType.Separator, item);
								if (s != null)
									s.AddAttributesToRender (w);
							}
							if (item < itms - 1 || show_empty_trailing_sep)
								w.RenderBeginTag (HtmlTextWriterTag.Td);
						}

						if (item < itms - 1)
							user.RenderItem (ListItemType.Separator, item, this, w);

						if (table && (item < itms - 1 || show_empty_trailing_sep))
							w.RenderEndTag (); // td
					}
				}
				if (oti) {
				} else if (table) {
					w.RenderEndTag (); // tr
				} else if (r != rows - 1) {
					RenderBr(w);
				}
				
				if (sep && r != rows - 1 /* no sep on last item */ && cols == 1) {
					if (table) {
						w.RenderBeginTag (HtmlTextWriterTag.Tr);
						Style s = user.GetItemStyle (ListItemType.Separator, r);
						if (s != null)
							s.AddAttributesToRender (w);
					
						w.RenderBeginTag (HtmlTextWriterTag.Td);
					}
					
					user.RenderItem (ListItemType.Separator, r, this, w);

					if (table) {
						w.RenderEndTag (); // td
						w.RenderEndTag (); // tr
					} else if (!oti) {
						RenderBr (w);
					}
				}
			}

			// Render the footer
			if (user.HasFooter) {
				if (oti)
					user.RenderItem (ListItemType.Footer, -1, this, w);
				else if (table) {
					w.RenderBeginTag (HtmlTextWriterTag.Tr);
					if (hdr_span != 1)
						w.AddAttribute (HtmlTextWriterAttribute.Colspan, hdr_span.ToString (), false);

					Style s = user.GetItemStyle (ListItemType.Footer, -1);
					if (s != null)
						s.AddAttributesToRender (w);
					
					w.RenderBeginTag (HtmlTextWriterTag.Td);
					user.RenderItem (ListItemType.Footer, -1, this, w);
					w.RenderEndTag (); // td
					w.RenderEndTag (); // tr
				} else {
					// avoid dups on 0 items
					if (itms != 0)
						RenderBr (w);
					user.RenderItem (ListItemType.Footer, -1, this, w);
				}
			}
			if (! oti)
				w.RenderEndTag (); // table/span
			
		}
        private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
        {
            int repeatedItemCount = user.RepeatedItemCount;
            int repeatColumns = this.repeatColumns;
            int num3 = 0;
            if (repeatColumns == 0)
            {
                repeatColumns = repeatedItemCount;
            }
            WebControl control = null;
            bool flag = false;
            switch (this.repeatLayout)
            {
                case System.Web.UI.WebControls.RepeatLayout.Table:
                    control = new Table();
                    if (this.Caption.Length != 0)
                    {
                        ((Table) control).Caption = this.Caption;
                        ((Table) control).CaptionAlign = this.CaptionAlign;
                    }
                    flag = true;
                    break;

                case System.Web.UI.WebControls.RepeatLayout.Flow:
                    control = new WebControl(HtmlTextWriterTag.Span);
                    break;
            }
            bool hasSeparators = user.HasSeparators;
            control.ID = baseControl.ClientID;
            control.CopyBaseAttributes(baseControl);
            control.ApplyStyle(controlStyle);
            control.RenderBeginTag(writer);
            if (user.HasHeader)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if ((repeatColumns != 1) || hasSeparators)
                    {
                        int num4 = repeatColumns;
                        if (hasSeparators)
                        {
                            num4 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num4.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                    }
                    Style itemStyle = user.GetItemStyle(ListItemType.Header, -1);
                    if (itemStyle != null)
                    {
                        itemStyle.AddAttributesToRender(writer);
                    }
                    if (this.useAccessibleHeader)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                }
                user.RenderItem(ListItemType.Header, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                else if (repeatColumns < repeatedItemCount)
                {
                    if (this.EnableLegacyRendering)
                    {
                        writer.WriteObsoleteBreak();
                    }
                    else
                    {
                        writer.WriteBreak();
                    }
                }
            }
            for (int i = 0; i < repeatedItemCount; i++)
            {
                if (flag && (num3 == 0))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }
                if (flag)
                {
                    Style style2 = user.GetItemStyle(ListItemType.Item, i);
                    if (style2 != null)
                    {
                        style2.AddAttributesToRender(writer);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Item, i, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                }
                if (hasSeparators && (i != (repeatedItemCount - 1)))
                {
                    if (flag)
                    {
                        Style style3 = user.GetItemStyle(ListItemType.Separator, i);
                        if (style3 != null)
                        {
                            style3.AddAttributesToRender(writer);
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    }
                    user.RenderItem(ListItemType.Separator, i, this, writer);
                    if (flag)
                    {
                        writer.RenderEndTag();
                    }
                }
                num3++;
                if (flag && (i == (repeatedItemCount - 1)))
                {
                    int num6 = repeatColumns - num3;
                    if (hasSeparators)
                    {
                        int num7 = (num6 * 2) + 1;
                        if (num7 > num6)
                        {
                            num6 = num7;
                        }
                    }
                    for (int j = 0; j < num6; j++)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.RenderEndTag();
                    }
                }
                if ((num3 == repeatColumns) || (i == (repeatedItemCount - 1)))
                {
                    if (flag)
                    {
                        writer.RenderEndTag();
                    }
                    else if (repeatColumns < repeatedItemCount)
                    {
                        if (this.EnableLegacyRendering)
                        {
                            writer.WriteObsoleteBreak();
                        }
                        else
                        {
                            writer.WriteBreak();
                        }
                    }
                    num3 = 0;
                }
            }
            if (user.HasFooter)
            {
                if (flag)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    if ((repeatColumns != 1) || hasSeparators)
                    {
                        int num9 = repeatColumns;
                        if (hasSeparators)
                        {
                            num9 += repeatColumns;
                        }
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num9.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    Style style4 = user.GetItemStyle(ListItemType.Footer, -1);
                    if (style4 != null)
                    {
                        style4.AddAttributesToRender(writer);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                user.RenderItem(ListItemType.Footer, -1, this, writer);
                if (flag)
                {
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
            }
            control.RenderEndTag(writer);
        }