XhtmlTextWriter 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 XhtmlTextWriter 類別的新執行個體。
多載
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