HtmlTextWriter Konstruktory

Definice

Inicializuje novou instanci HtmlTextWriter třídy.

Přetížení

Name Description
HtmlTextWriter(TextWriter)

Inicializuje novou instanci HtmlTextWriter třídy, která používá výchozí řetězec tabulátoru.

HtmlTextWriter(TextWriter, String)

Inicializuje novou instanci HtmlTextWriter třídy se zadaným znakem řetězce tabulátoru.

HtmlTextWriter(TextWriter)

Inicializuje novou instanci HtmlTextWriter třídy, která používá výchozí řetězec tabulátoru.

public:
 HtmlTextWriter(System::IO::TextWriter ^ writer);
public HtmlTextWriter(System.IO.TextWriter writer);
new System.Web.UI.HtmlTextWriter : System.IO.TextWriter -> System.Web.UI.HtmlTextWriter
Public Sub New (writer As TextWriter)

Parametry

writer
TextWriter

Instance TextWriter , která vykresluje obsah revizí.

Příklady

Následující příklad kódu ukazuje, jak použít HtmlTextWriter(TextWriter) konstruktor k vytvoření vlastní HtmlTextWriter objekt s názvem StyledLabelHtmlWriter. Pokud je MyPage vlastní třída, která je odvozena z Page třídy, požadována klientským prohlížečem, používá StyledLabelHtmlWriter třídu k vykreslení jeho obsahu do výstupního datového proudu.

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the StyledLabelHtmlWriter class to render its content.
public ref class MyPage: public Page
{
protected:
   virtual HtmlTextWriter^ CreateHtmlTextWriter( TextWriter^ writer ) override
   {
      return gcnew HtmlStyledLabelWriter( writer );
   }
};

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the HtmlStyledLabelWriter class to render its content.
[AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
public class MyPage : Page
{
    protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlStyledLabelWriter(writer);
    }
}
' A custom class that overrides the CreateHtmlTextWriter method.
' This page uses the StyledLabelHtmlWriter to render its content.  
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyPage
    Inherits Page

    Protected Overrides Function CreateHtmlTextWriter(ByVal writer As TextWriter) As HtmlTextWriter
        Return New HtmlStyledLabelWriter(writer)
    End Function 'CreateHtmlTextWriter
End Class

Poznámky

Přetížení HtmlTextWriter konstruktoru HtmlTextWriter(TextWriter) používá konstantu DefaultTabString při odsazení řádku. HtmlTextWriter(TextWriter, String) Volá přetížení pro inicializaci nové instance.

Viz také

Platí pro

HtmlTextWriter(TextWriter, String)

Inicializuje novou instanci HtmlTextWriter třídy se zadaným znakem řetězce tabulátoru.

public:
 HtmlTextWriter(System::IO::TextWriter ^ writer, System::String ^ tabString);
public HtmlTextWriter(System.IO.TextWriter writer, string tabString);
new System.Web.UI.HtmlTextWriter : System.IO.TextWriter * string -> System.Web.UI.HtmlTextWriter
Public Sub New (writer As TextWriter, tabString As String)

Parametry

writer
TextWriter

Tím TextWriter se vykreslí obsah revizí.

tabString
String

Řetězec, který se má použít k vykreslení odsazení řádku.

Příklady

Následující příklad kódu ukazuje, jak použít HtmlTextWriter(TextWriter) konstruktor k vytvoření vlastní HtmlTextWriter objekt s názvem StyledLabelHtmlWriter. Pokud je MyPage vlastní třída, která je odvozena z Page třídy, požadována klientským prohlížečem, používá StyledLabelHtmlWriter třídu k vykreslení jeho obsahu do výstupního datového proudu.

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the StyledLabelHtmlWriter class to render its content.
public ref class MyPage: public Page
{
protected:
   virtual HtmlTextWriter^ CreateHtmlTextWriter( TextWriter^ writer ) override
   {
      return gcnew HtmlStyledLabelWriter( writer );
   }
};

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the HtmlStyledLabelWriter class to render its content.
[AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
public class MyPage : Page
{
    protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlStyledLabelWriter(writer);
    }
}
' A custom class that overrides the CreateHtmlTextWriter method.
' This page uses the StyledLabelHtmlWriter to render its content.  
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyPage
    Inherits Page

    Protected Overrides Function CreateHtmlTextWriter(ByVal writer As TextWriter) As HtmlTextWriter
        Return New HtmlStyledLabelWriter(writer)
    End Function 'CreateHtmlTextWriter
End Class

Poznámky

Přetížení HtmlTextWriter konstruktoru HtmlTextWriter(TextWriter, String) používá tabString , když je nutné odsazení řádku. Volá TextWriter.TextWriter(IFormatProvider) základní konstruktor pro inicializaci nové instance.

Viz také

Platí pro