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


C# HtmlTextWriter.BeginTag方法代码示例

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


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

示例1: RenderContents

        /// <summary>
        /// Renders the contents of the control to the specified writer. This method is used primarily by control developers.
        /// </summary>
        /// <param name="writer">A <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client.</param>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (this.EventArgs != null) {

                writer.RenderTag(HtmlTextWriterTag.Legend, "Server side rendered content");

                // start address/location
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#EEE");
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "Start address: ");
                    writer.Write(this.EventArgs.StartAddress);
                    writer.RenderTag(HtmlTextWriterTag.B, " / Start location: ");
                    writer.Write(this.EventArgs.StartLocation.ToString());
                }

                // steps
                foreach (var step in this.EventArgs.Steps) {
                    writer.AddStyleAttribute("border-bottom", "solid 1px #CCC");
                    using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                        writer.Write(step.Instructions);
                        writer.Write(" | ");
                        writer.RenderTag(HtmlTextWriterTag.B, "Distance: ");
                        writer.Write(step.Distance.Text);
                        writer.Write(" | ");
                        writer.RenderTag(HtmlTextWriterTag.B, "Duration: ");
                        writer.Write(step.Duration.Text);
                    }
                }

                // end address/location
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#EEE");
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "End address: ");
                    writer.Write(this.EventArgs.EndAddress);
                    writer.RenderTag(HtmlTextWriterTag.B, " / End location: ");
                    writer.Write(this.EventArgs.EndLocation.ToString());
                }

                // distance
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "Total Distance: ");
                    writer.Write(this.EventArgs.Distance.Text);
                }
                // durarion
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "Total Duration: ");
                    writer.Write(this.EventArgs.Duration.Text);
                }
            }
        }
开发者ID:ziad007,项目名称:URI2,代码行数:54,代码来源:RouteRenderer.cs


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