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
注解
将XhtmlTextWriterTextWriter对象作为参数的构造函数调用第二个构造函数,并传递两个参数值:
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