当前位置: 首页>>代码示例>>C#>>正文


C# WebControl.RenderEndTag方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.WebControl.RenderEndTag方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.RenderEndTag方法的具体用法?C# WebControl.RenderEndTag怎么用?C# WebControl.RenderEndTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.WebControl的用法示例。


在下文中一共展示了WebControl.RenderEndTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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();
                    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)
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:RepeatInfo.cs

示例2: RenderContents

        /// <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 );
                }
            }
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:94,代码来源:RadioButtonListAdapter.cs

示例3: RenderHorizontalRepeater

        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)
                {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:RepeatInfo.cs


注:本文中的System.Web.UI.WebControls.WebControl.RenderEndTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。