ChtmlTextWriter クラス
アセンブリ: System.Web (system.web.dll 内)


コンパクト HTML (cHTML: Compact HTML) は、HTML 2.0、HTML 3.2、および HTML 4.0 のサブセットで、メモリ、CPU パワー、書式設定機能、および入力オプション数に制限があり、画面が小さいデバイス (携帯電話など) 用に設計された HTML です。したがって、cHTML では以下をサポートしません。
ChtmlTextWriter クラスは Html32TextWriter クラスからの派生クラスで、そのほとんどの機能が Html32TextWriter と、すべてのマークアップ テキスト ライタの基本クラスである HtmlTextWriter クラスから提供されます。

CustomChtmlTextWriter という名前のクラスを、ChtmlTextWriter クラスから派生して作成する方法を次のコード例に示します。2 つのコンストラクタを作成し、OnAttributeRender メソッドをオーバーライドして、bgcolor スタイル属性が ChtmlTextWriter オブジェクトの出力ストリームに書き込まれないようにします。また、ChtmlCustomPageAdapter という名前のクラスも作成し、CustomChtmlTextWriter クラスのインスタンスを作成して返す CreateCustomChtmlTextWriter メソッドを定義します。そして、CustomChtmlTextWriter が、cHTML マークアップ対応ブラウザを持つデバイスにページの cHTML コンテンツを出力します。
' Create a class that derives from the ' ChtmlTextWriter class. Imports System Imports System.IO Imports System.Web.UI Imports System.Web.UI.WebControls.Adapters Namespace AspNet.Samples.VB Public Class CustomChtmlTextWriter Inherits ChtmlTextWriter ' Create two constructors for the new ' text writer. Public Sub New(ByVal writer As TextWriter) MyClass.New(writer, DefaultTabString) End Sub Public Sub New(ByVal writer As TextWriter, ByVal tabString As String) MyBase.New(writer, tabString) End Sub ' Override the OnAttributeRender method to ' not render the bgcolor attribute, which is ' not supported in CHTML. Protected Overrides Function OnAttributeRender(ByVal name As String, ByVal value As String, ByVal key As HtmlTextWriterAttribute) As Boolean If (String.Equals("bgcolor", name)) Then Return False End If ' Call the ChtmlTextWriter version of ' the OnAttributeRender method. MyBase.OnAttributeRender(name, value, key) End Function End Class ' Derive from the WebControlAdapter class, ' provide a CreateCustomChtmlTextWriter ' method to attach the custom writer. Public Class ChtmlCustomPageAdapter Inherits WebControlAdapter Protected Friend Function CreateCustomChtmlTextWriter( _ ByVal writer As TextWriter) As ChtmlTextWriter Return New CustomChtmlTextWriter(writer) End Function End Class End Namespace
// 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); } } }


System.MarshalByRefObject
System.IO.TextWriter
System.Web.UI.HtmlTextWriter
System.Web.UI.Html32TextWriter
System.Web.UI.ChtmlTextWriter


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からChtmlTextWriter クラスを検索する場合は、下記のリンクをクリックしてください。

- ChtmlTextWriter クラスのページへのリンク