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