XhtmlTextWriter 构造函数
定义
初始化 XhtmlTextWriter 类的新实例。Initializes a new instance of the XhtmlTextWriter class.
重载
| XhtmlTextWriter(TextWriter) |
初始化 XhtmlTextWriter 类的新实例,该类使用在 DefaultTabString 字段中指定的行缩进。Initializes a new instance of the XhtmlTextWriter class that uses the line indentation that is specified in the DefaultTabString field. 如果不希望更改默认行缩进,请使用 XhtmlTextWriter(TextWriter) 构造函数。Use the XhtmlTextWriter(TextWriter) constructor if you do not want to change the default line indentation. |
| XhtmlTextWriter(TextWriter, String) |
使用指定的行缩进初始化 XhtmlTextWriter 类的新实例。Initializes a new instance of the XhtmlTextWriter class with the specified line indentation. |
XhtmlTextWriter(TextWriter)
初始化 XhtmlTextWriter 类的新实例,该类使用在 DefaultTabString 字段中指定的行缩进。Initializes a new instance of the XhtmlTextWriter class that uses the line indentation that is specified in the DefaultTabString field. 如果不希望更改默认行缩进,请使用 XhtmlTextWriter(TextWriter) 构造函数。Use the XhtmlTextWriter(TextWriter) constructor if you do not want to change the default line indentation.
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
呈现 XHTML 内容的 TextWriter 实例。A TextWriter instance that renders the XHTML content.
示例
下面的代码示例演示如何 HtmlTextWriter 为从类派生的自定义类,为直接或间接从类派生的所有类创建两个构造函数 XhtmlTextWriter 。The following code example demonstrates how to create the two constructors, which is standard for all classes that derive directly or indirectly from the HtmlTextWriter class, for a custom class that is derived from the XhtmlTextWriter class.
// 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 调用第二个构造函数,同时传递两个参数值:The XhtmlTextWriter constructor that takes a TextWriter object as a parameter calls the second constructor, passing two parameter values:
TextWriter 实例。The TextWriter instance.
在字段中指定的字符串值 DefaultTabString ,用于定义 XHTML 文本编写器使用的制表符间距。The string value that is specified in the DefaultTabString field, which defines the tab spacing that is used by the XHTML text writer.
适用于
XhtmlTextWriter(TextWriter, String)
使用指定的行缩进初始化 XhtmlTextWriter 类的新实例。Initializes a new instance of the XhtmlTextWriter class with the specified line indentation.
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
呈现 XHTML 内容的 TextWriter 实例。A TextWriter instance that renders the XHTML content.
- tabString
- String
用于呈现行缩进的字符串。The string used to render a line indentation.
示例
下面的代码示例演示如何 HtmlTextWriter 为从类派生的自定义类,为直接或间接从类派生的所有类创建两个构造函数 XhtmlTextWriter 。The following code example demonstrates how to create the two constructors, which is standard for all classes that derive directly or indirectly from the HtmlTextWriter class, for a custom class that is derived from the XhtmlTextWriter class.
// 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