XhtmlTextWriter Konstruktory

Definice

Inicializuje novou instanci XhtmlTextWriter třídy.

Přetížení

Name Description
XhtmlTextWriter(TextWriter)

Inicializuje novou instanci XhtmlTextWriter třídy, která používá odsazení řádku, která je zadána DefaultTabString v poli. XhtmlTextWriter(TextWriter) Konstruktor použijte, pokud nechcete změnit výchozí odsazení řádku.

XhtmlTextWriter(TextWriter, String)

Inicializuje novou instanci XhtmlTextWriter třídy se zadaným odsazením řádku.

XhtmlTextWriter(TextWriter)

Inicializuje novou instanci XhtmlTextWriter třídy, která používá odsazení řádku, která je zadána DefaultTabString v poli. XhtmlTextWriter(TextWriter) Konstruktor použijte, pokud nechcete změnit výchozí odsazení řádku.

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)

Parametry

writer
TextWriter

Instance TextWriter , která vykreslí obsah XHTML.

Příklady

Následující příklad kódu ukazuje, jak vytvořit dva konstruktory, což je standardní pro všechny třídy, které jsou odvozeny přímo nebo nepřímo z HtmlTextWriter třídy, pro vlastní třídu odvozené z XhtmlTextWriter třídy.

// 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

Poznámky

Konstruktor XhtmlTextWriter , který přebírá TextWriter objekt jako parametr, volá druhý konstruktor a předává dvě hodnoty parametrů:

  • Instance TextWriter.

  • Řetězcová hodnota zadaná v DefaultTabString poli, která definuje mezery tabulátoru, které používá zapisovač textu XHTML.

Platí pro

XhtmlTextWriter(TextWriter, String)

Inicializuje novou instanci XhtmlTextWriter třídy se zadaným odsazením řádku.

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)

Parametry

writer
TextWriter

Instance TextWriter , která vykreslí obsah XHTML.

tabString
String

Řetězec použitý k vykreslení odsazení řádku.

Příklady

Následující příklad kódu ukazuje, jak vytvořit dva konstruktory, což je standardní pro všechny třídy, které jsou odvozeny přímo nebo nepřímo z HtmlTextWriter třídy, pro vlastní třídu odvozené z XhtmlTextWriter třídy.

// 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

Platí pro