本文整理汇总了C#中System.Web.UI.ChtmlTextWriter类的典型用法代码示例。如果您正苦于以下问题:C# ChtmlTextWriter类的具体用法?C# ChtmlTextWriter怎么用?C# ChtmlTextWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChtmlTextWriter类属于System.Web.UI命名空间,在下文中一共展示了ChtmlTextWriter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomChtmlTextWriter
// Create a class that derives from the
// ChtmlTextWriter class.
using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls.Adapters;
namespace AspNet.Samples.CS
{
public class CustomChtmlTextWriter : ChtmlTextWriter
{
// Create two constructors for the new
// text writer.
public CustomChtmlTextWriter(TextWriter writer) : base(writer, DefaultTabString)
{
}
public CustomChtmlTextWriter(TextWriter writer, String tabString)
: base(writer, tabString)
{
}
// Override the OnAttributeRender method to
// not render the bgcolor attribute, which is
// not supported in CHTML.
protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
{
if (String.Equals("bgcolor", name))
{
return false;
}
// Call the ChtmlTextWriter version of the
// the OnAttributeRender method.
return base.OnAttributeRender(name, value, key);
}
}
// Derive from the WebControlAdapter class,
// provide a CreateCustomChtmlTextWriter
// method to attach to the custom writer.
public class ChtmlCustomPageAdapter : WebControlAdapter
{
protected internal ChtmlTextWriter CreateCustomChtmlTextWriter(
TextWriter writer)
{
return new CustomChtmlTextWriter(writer);
}
}
}