RenderBeginTag() публичный Метод

public RenderBeginTag ( System.Web.UI.HtmlTextWriter writer ) : void
writer System.Web.UI.HtmlTextWriter
Результат void
Пример #1
0
        /// <summary>
        /// Returns the report control as html string.
        /// </summary>
        public static string ToHtml(this Web.UI.WebControls.WebControl webControl)
        {
            string result = "";

            StringBuilder  sb;
            StringWriter   stWriter;
            HtmlTextWriter htmlWriter;

            sb         = new StringBuilder();
            stWriter   = new StringWriter(sb);
            htmlWriter = new HtmlTextWriter(stWriter);

            //this.RenderControl(htmlWriter);
            webControl.RenderBeginTag(htmlWriter);

            foreach (Control control in webControl.Controls)
            {
                control.RenderControl(htmlWriter);
            }

            webControl.RenderEndTag(htmlWriter);

            result = sb.ToString();

            return(result);
        }
Пример #2
0
        void RenderBeginTag(HtmlTextWriter w, Style s, WebControl wc)
        {
            WebControl c;

            switch (RepeatLayout)
            {
            case RepeatLayout.Table:
                c = new Table();
                break;

            case RepeatLayout.Flow:
                c = new Label();
                break;

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

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

            default:
                throw new InvalidOperationException(String.Format("Unsupported RepeatLayout value '{0}'.", RepeatLayout));
            }

            c.ID = wc.ClientID;
            c.CopyBaseAttributes(wc);
            c.ApplyStyle(s);
            c.Enabled = wc.IsEnabled;
            c.RenderBeginTag(w);
        }
Пример #3
0
		void RenderBeginTag (HtmlTextWriter w, Style s, WebControl wc)
		{
			WebControl c;
			switch (RepeatLayout) {	
				case RepeatLayout.Table:
					c = new Table ();
					break;
					
				case RepeatLayout.Flow:
					c = new Label ();
					break;
				case RepeatLayout.OrderedList:
					c = new WebControl (HtmlTextWriterTag.Ol);
					break;

				case RepeatLayout.UnorderedList:
					c = new WebControl (HtmlTextWriterTag.Ul);
					break;
				default:
					throw new InvalidOperationException (String.Format ("Unsupported RepeatLayout value '{0}'.", RepeatLayout));
			}

			c.ID = wc.ClientID;
			c.CopyBaseAttributes (wc);
			c.ApplyStyle (s);
			c.Enabled = wc.IsEnabled;
			c.RenderBeginTag (w);
		}
Пример #4
0
		public void RenderBeginTag_BorderWidth_table ()
		{
			HtmlTextWriter writer = WebControlTest.GetWriter ();
			WebControl wc = new WebControl (HtmlTextWriterTag.Table);
			wc.BorderWidth = Unit.Pixel (1);
			wc.RenderBeginTag (writer);
			string s = writer.InnerWriter.ToString ();
			Assert.AreEqual ("<table style=\"border-width:1px;border-style:solid;\">\n", s, "BorderWidth");
		}
Пример #5
0
		public void RenderBeginTag_BorderWidth_span ()
		{
			HtmlTextWriter writer = WebControlTest.GetWriter ();
			WebControl wc = new WebControl (HtmlTextWriterTag.Span);
			wc.BorderWidth = Unit.Pixel (1);
			wc.RenderBeginTag (writer);
			string s = writer.InnerWriter.ToString ();
#if NET_2_0
			Assert.AreEqual ("<span style=\"display:inline-block;border-width:1px;border-style:solid;\">", s, "BorderWidth");
#else
			Assert.AreEqual ("<span style=\"border-width:1px;border-style:solid;\">", s, "BorderWidth");
#endif
		}
Пример #6
0
		public void RenderBeginTag_Style ()
		{
			HtmlTextWriter writer = WebControlTest.GetWriter ();
			WebControl wc = new WebControl (HtmlTextWriterTag.Table);
			wc.BackColor = Color.Aqua;
			wc.RenderBeginTag (writer);
			string s = writer.InnerWriter.ToString ();
			Assert.AreEqual ("<table style=\"background-color:Aqua;\">\n", s, "BackColor");

			writer = WebControlTest.GetWriter ();
			wc.BackColor = new Color ();
			Assert.IsTrue (wc.BackColor.IsEmpty, "IsEmpty");
			wc.RenderBeginTag (writer);
			s = writer.InnerWriter.ToString ();
			Assert.AreEqual ("<table>\n", s, "-BackColor");
		}
Пример #7
0
		public void RenderBeginTag_Attributes ()
		{
			HtmlTextWriter writer = WebControlTest.GetWriter ();
			WebControl wc = new WebControl (HtmlTextWriterTag.Table);
			wc.ID = "test1";
			wc.RenderBeginTag (writer);
			string s = writer.InnerWriter.ToString ();
			Assert.AreEqual ("<table id=\"test1\">\n", s, "ID");

			writer = WebControlTest.GetWriter ();
			wc.ID = null;
			Assert.IsNull (wc.ID, "ID");
			wc.RenderBeginTag (writer);
			s = writer.InnerWriter.ToString ();
			Assert.AreEqual ("<table>\n", s, "-ID");
		}
Пример #8
0
		public void RenderBeginTag_TagOnly ()
		{
			HtmlTextWriter writer = WebControlTest.GetWriter ();
			WebControl wc = new WebControl (HtmlTextWriterTag.Table);
			wc.RenderBeginTag (writer);
			string s = writer.InnerWriter.ToString ();
			Assert.AreEqual ("<table>\n", s, "table");
		}
Пример #9
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);
        }
Пример #10
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);
        }
        /// <summary>
        /// Generates the target-specific inner markup for the Web control to which the control adapter is attached.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> containing methods to render the target-specific output.</param>
        protected override void RenderContents( System.Web.UI.HtmlTextWriter writer )
        {
            RadioButtonList rbl = Control as RadioButtonList;
            if ( rbl != null )
            {
                PostBackOptions postBackOption = null;

                if ( rbl.AutoPostBack )
                {
                    postBackOption = new PostBackOptions( rbl, string.Empty );
                    if ( rbl.CausesValidation && this.Page.GetValidators( rbl.ValidationGroup ).Count > 0 )
                    {
                        postBackOption.PerformValidation = true;
                        postBackOption.ValidationGroup = rbl.ValidationGroup;
                    }
                    if ( this.Page.Form != null )
                    {
                        postBackOption.AutoPostBack = true;
                    }
                }

                WebControl control = new WebControl(HtmlTextWriterTag.Span);
                control.ID = rbl.ClientID;
                control.CopyBaseAttributes(rbl);
                control.RenderBeginTag(writer);

                int i = 0;
                foreach ( ListItem li in rbl.Items )
                {
                    writer.WriteLine();

                    if ( rbl.RepeatDirection == RepeatDirection.Vertical )
                    {
                        writer.AddAttribute( "class", "radio" );
                        writer.RenderBeginTag( HtmlTextWriterTag.Div );
                    }
                    else
                    {
                        writer.AddAttribute( "class", "radio-inline" );
                    }

                    writer.RenderBeginTag( HtmlTextWriterTag.Label );

                    string itemId = string.Format( "{0}_{1}", rbl.ClientID, i++ );
                    writer.AddAttribute( "id", itemId );
                    writer.AddAttribute( "type", "radio" );
                    writer.AddAttribute( "name", rbl.UniqueID );
                    writer.AddAttribute( "value", li.Value );
                    if ( li.Selected )
                    {
                        writer.AddAttribute( "checked", "checked" );
                    }

                    foreach ( var attributeKey in li.Attributes.Keys )
                    {
                        var key = attributeKey as string;
                        writer.AddAttribute( key, li.Attributes[key] );
                    }

                    if ( postBackOption != null )
                    {
                        writer.AddAttribute( HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference( postBackOption, true ) );
                    }

                    writer.RenderBeginTag( HtmlTextWriterTag.Input );
                    writer.RenderEndTag();

                    writer.Write( li.Text );

                    writer.RenderEndTag();      // Label

                    if ( rbl.RepeatDirection == RepeatDirection.Vertical )
                    {
                        writer.RenderEndTag();  // Div
                    }

                    if ( rbl.Page != null )
                    {
                        rbl.Page.ClientScript.RegisterForEventValidation( rbl.UniqueID, li.Value );
                    }
                }

                control.RenderEndTag( writer );

                if ( rbl.Page != null )
                {
                    rbl.Page.ClientScript.RegisterForEventValidation( rbl.UniqueID );
                }
            }
        }
Пример #12
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);
        }
Пример #13
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);
        }
        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);
        }