HtmlTextWriter コンストラクター

定義

HtmlTextWriter クラスの新しいインスタンスを初期化します。

オーバーロード

HtmlTextWriter(TextWriter)

既定のタブ文字列を使用する HtmlTextWriter クラスの新しいインスタンスを初期化します。

HtmlTextWriter(TextWriter, String)

タブ文字列を指定して、HtmlTextWriter クラスの新しいインスタンスを初期化します。

HtmlTextWriter(TextWriter)

既定のタブ文字列を使用する HtmlTextWriter クラスの新しいインスタンスを初期化します。

public:
 HtmlTextWriter(System::IO::TextWriter ^ writer);
public HtmlTextWriter (System.IO.TextWriter writer);
new System.Web.UI.HtmlTextWriter : System.IO.TextWriter -> System.Web.UI.HtmlTextWriter
Public Sub New (writer As TextWriter)

パラメーター

writer
TextWriter

マークアップ コンテンツをレンダリングする TextWriter インスタンス。

次のコード例では、 コンストラクターを使用して という名前StyledLabelHtmlWriterHtmlTextWriter(TextWriter)カスタム HtmlTextWriter オブジェクトを作成する方法を示します。 MyPageクラスからPage派生したカスタム クラスがクライアント ブラウザーによって要求されると、 クラスをStyledLabelHtmlWriter使用してそのコンテンツを出力ストリームにレンダリングします。

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the StyledLabelHtmlWriter class to render its content.
public ref class MyPage: public Page
{
protected:
   virtual HtmlTextWriter^ CreateHtmlTextWriter( TextWriter^ writer ) override
   {
      return gcnew HtmlStyledLabelWriter( writer );
   }
};

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the HtmlStyledLabelWriter class to render its content.
[AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
public class MyPage : Page
{
    protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlStyledLabelWriter(writer);
    }
}
' A custom class that overrides the CreateHtmlTextWriter method.
' This page uses the StyledLabelHtmlWriter to render its content.  
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyPage
    Inherits Page

    Protected Overrides Function CreateHtmlTextWriter(ByVal writer As TextWriter) As HtmlTextWriter
        Return New HtmlStyledLabelWriter(writer)
    End Function 'CreateHtmlTextWriter
End Class

注釈

コンストラクターのオーバーロードは HtmlTextWriterHtmlTextWriter(TextWriter) 行のインデントが DefaultTabString 必要な場合に 定数を使用します。 オーバーロードを HtmlTextWriter(TextWriter, String) 呼び出して新しいインスタンスを初期化します。

こちらもご覧ください

適用対象

HtmlTextWriter(TextWriter, String)

タブ文字列を指定して、HtmlTextWriter クラスの新しいインスタンスを初期化します。

public:
 HtmlTextWriter(System::IO::TextWriter ^ writer, System::String ^ tabString);
public HtmlTextWriter (System.IO.TextWriter writer, string tabString);
new System.Web.UI.HtmlTextWriter : System.IO.TextWriter * string -> System.Web.UI.HtmlTextWriter
Public Sub New (writer As TextWriter, tabString As String)

パラメーター

writer
TextWriter

マークアップ コンテンツをレンダリングする TextWriter

tabString
String

行のインデントをレンダリングするために使用する文字列。

次のコード例では、 コンストラクターを使用して という名前StyledLabelHtmlWriterHtmlTextWriter(TextWriter)カスタム HtmlTextWriter オブジェクトを作成する方法を示します。 MyPageクラスからPage派生したカスタム クラスがクライアント ブラウザーによって要求されると、 クラスをStyledLabelHtmlWriter使用してそのコンテンツを出力ストリームにレンダリングします。

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the StyledLabelHtmlWriter class to render its content.
public ref class MyPage: public Page
{
protected:
   virtual HtmlTextWriter^ CreateHtmlTextWriter( TextWriter^ writer ) override
   {
      return gcnew HtmlStyledLabelWriter( writer );
   }
};

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the HtmlStyledLabelWriter class to render its content.
[AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
public class MyPage : Page
{
    protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlStyledLabelWriter(writer);
    }
}
' A custom class that overrides the CreateHtmlTextWriter method.
' This page uses the StyledLabelHtmlWriter to render its content.  
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyPage
    Inherits Page

    Protected Overrides Function CreateHtmlTextWriter(ByVal writer As TextWriter) As HtmlTextWriter
        Return New HtmlStyledLabelWriter(writer)
    End Function 'CreateHtmlTextWriter
End Class

注釈

コンストラクターのオーバーロードは HtmlTextWriter 、行の HtmlTextWriter(TextWriter, String) インデントが必要な場合に を使用 tabString します。 基本コンストラクターを TextWriter.TextWriter(IFormatProvider) 呼び出して、新しいインスタンスを初期化します。

こちらもご覧ください

適用対象