本文整理汇总了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);
}
}
}