HtmlTextWriter コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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 インスタンス。
例
次のコード例では、HtmlTextWriter(TextWriter) コンストラクターを使用して、StyledLabelHtmlWriterという名前のカスタム HtmlTextWriter オブジェクトを作成する方法を示します。
Page クラスから派生した MyPage カスタム クラスがクライアント ブラウザーによって要求されると、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(TextWriter) コンストラクターのHtmlTextWriterオーバーロードは、行のインデントが必要な場合に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
行インデントのレンダリングに使用する文字列。
例
次のコード例では、HtmlTextWriter(TextWriter) コンストラクターを使用して、StyledLabelHtmlWriterという名前のカスタム HtmlTextWriter オブジェクトを作成する方法を示します。
Page クラスから派生した MyPage カスタム クラスがクライアント ブラウザーによって要求されると、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(TextWriter, String) コンストラクターのHtmlTextWriterオーバーロードは、行のインデントが必要な場合にtabStringを使用します。
TextWriter.TextWriter(IFormatProvider)基本コンストラクターを呼び出して、新しいインスタンスを初期化します。