HtmlTextWriter Konstruktory

Definice

Inicializuje novou instanci HtmlTextWriter třídy.

Přetížení

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á vykreslí obsah značek.

Příklady

Následující příklad kódu ukazuje, jak pomocí konstruktoru HtmlTextWriter(TextWriter) vytvořit vlastní HtmlTextWriter objekt s názvem StyledLabelHtmlWriter. MyPage Když klientský prohlížeč požaduje vlastní třídu, která je odvozena od Page třídy, použije StyledLabelHtmlWriter třídu k vykreslení jejího 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 , když je nutné odsazení řádku. Zavolá HtmlTextWriter(TextWriter, String) přetížení k 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

Ten TextWriter , který vykreslí obsah značek.

tabString
String

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

Příklady

Následující příklad kódu ukazuje, jak pomocí konstruktoru HtmlTextWriter(TextWriter) vytvořit vlastní HtmlTextWriter objekt s názvem StyledLabelHtmlWriter. MyPage Když klientský prohlížeč požaduje vlastní třídu, která je odvozena od Page třídy, použije StyledLabelHtmlWriter třídu k vykreslení jejího 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. Zavolá TextWriter.TextWriter(IFormatProvider) základní konstruktor pro inicializaci nové instance.

Viz také

Platí pro