語言

XhtmlTextWriter 建構函式

定義

初始化 XhtmlTextWriter 類別的新執行個體。

多載

名稱 Description
XhtmlTextWriter(TextWriter)

初始化使用欄位中指定的XhtmlTextWriter行縮排的新類別實例DefaultTabString。 如果你不想改變預設的行位縮排,請使用 XhtmlTextWriter(TextWriter) 建構器。

XhtmlTextWriter(TextWriter, String)

初始化一個新的類別實例 XhtmlTextWriter ,並以指定的行縮排。

XhtmlTextWriter(TextWriter)

初始化使用欄位中指定的XhtmlTextWriter行縮排的新類別實例DefaultTabString。 如果你不想改變預設的行位縮排,請使用 XhtmlTextWriter(TextWriter) 建構器。

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

參數

writer
TextWriter

一個 TextWriter 渲染 XHTML 內容的實例。

範例

以下程式碼範例示範如何建立兩個建構子,這是所有直接或間接衍生自 HtmlTextWriter 該類別的類別標準,適用於由該 XhtmlTextWriter 類別衍生的自訂類別。

// Create a class that inherits from XhtmlTextWriter.
[AspNetHostingPermission(SecurityAction.Demand, 
    Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, 
    Level=AspNetHostingPermissionLevel.Minimal)] 
public class CustomXhtmlTextWriter : XhtmlTextWriter
{
    // Create two constructors, following 
    // the pattern for implementing a
    // TextWriter constructor.
    public CustomXhtmlTextWriter(TextWriter writer) : 
        this(writer, DefaultTabString)
    {
    }

    public CustomXhtmlTextWriter(TextWriter writer, string tabString) : 
        base(writer, tabString)
    {
    }
' Create a class that inherits from XhtmlTextWriter.
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class CustomXhtmlTextWriter
    Inherits XhtmlTextWriter

    ' Create two constructors, following 
    ' the pattern for implementing a
    ' TextWriter constructor.
    Public Sub New(writer As TextWriter)
      MyClass.New(writer, DefaultTabString)
    End Sub


    Public Sub New(writer As TextWriter, tabString As String)
      MyBase.New(writer, tabString)
    End Sub

備註

以XhtmlTextWriter物件為參數的TextWriter建構子會呼叫第二個建構子,傳遞兩個參數值:

  • TextWriter 執行個體。

  • 欄位中指定的 DefaultTabString 字串值,定義了 XHTML 文字編寫器所使用的分頁間隔。

適用於

XhtmlTextWriter(TextWriter, String)

初始化一個新的類別實例 XhtmlTextWriter ,並以指定的行縮排。

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

參數

writer
TextWriter

一個 TextWriter 渲染 XHTML 內容的實例。

tabString
String

字串用於渲染行條縮排。

範例

以下程式碼範例示範如何建立兩個建構子,這是所有直接或間接衍生自 HtmlTextWriter 該類別的類別標準,適用於由該 XhtmlTextWriter 類別衍生的自訂類別。

// Create a class that inherits from XhtmlTextWriter.
[AspNetHostingPermission(SecurityAction.Demand, 
    Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, 
    Level=AspNetHostingPermissionLevel.Minimal)] 
public class CustomXhtmlTextWriter : XhtmlTextWriter
{
    // Create two constructors, following 
    // the pattern for implementing a
    // TextWriter constructor.
    public CustomXhtmlTextWriter(TextWriter writer) : 
        this(writer, DefaultTabString)
    {
    }

    public CustomXhtmlTextWriter(TextWriter writer, string tabString) : 
        base(writer, tabString)
    {
    }
' Create a class that inherits from XhtmlTextWriter.
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class CustomXhtmlTextWriter
    Inherits XhtmlTextWriter

    ' Create two constructors, following 
    ' the pattern for implementing a
    ' TextWriter constructor.
    Public Sub New(writer As TextWriter)
      MyClass.New(writer, DefaultTabString)
    End Sub


    Public Sub New(writer As TextWriter, tabString As String)
      MyBase.New(writer, tabString)
    End Sub

適用於