XhtmlTextWriter Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the XhtmlTextWriter class.
Overloads
XhtmlTextWriter(TextWriter) |
Initializes a new instance of the XhtmlTextWriter class that uses the line indentation that is specified in the DefaultTabString field. Use the XhtmlTextWriter(TextWriter) constructor if you do not want to change the default line indentation. |
XhtmlTextWriter(TextWriter, String) |
Initializes a new instance of the XhtmlTextWriter class with the specified line indentation. |
XhtmlTextWriter(TextWriter)
Initializes a new instance of the XhtmlTextWriter class that uses the line indentation that is specified in the DefaultTabString field. 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)
Parameters
- writer
- TextWriter
A TextWriter instance that renders the XHTML content.
Examples
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
Remarks
The XhtmlTextWriter constructor that takes a TextWriter object as a parameter calls the second constructor, passing two parameter values:
The TextWriter instance.
The string value that is specified in the DefaultTabString field, which defines the tab spacing that is used by the XHTML text writer.
Applies to
XhtmlTextWriter(TextWriter, String)
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)
Parameters
- writer
- TextWriter
A TextWriter instance that renders the XHTML content.
- tabString
- String
The string used to render a line indentation.
Examples
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