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
呈现 XHTML 内容的 TextWriter 实例。
示例
下面的代码示例演示如何为派生自 类的自定义类创建两个构造函数,这是直接或间接派生自 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
呈现 XHTML 内容的 TextWriter 实例。
- 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