HtmlTextWriter HtmlTextWriter HtmlTextWriter HtmlTextWriter Constructors

Definizione

Overload

HtmlTextWriter(TextWriter) HtmlTextWriter(TextWriter) HtmlTextWriter(TextWriter) HtmlTextWriter(TextWriter)

Inizializza una nuova istanza della classe HtmlTextWriter che utilizza una stringa di tabulazioni predefinita.Initializes a new instance of the HtmlTextWriter class that uses a default tab string.

HtmlTextWriter(TextWriter, String) HtmlTextWriter(TextWriter, String) HtmlTextWriter(TextWriter, String) HtmlTextWriter(TextWriter, String)

Inizializza una nuova istanza della classe HtmlTextWriter con un carattere di stringa di tabulazioni specificato.Initializes a new instance of the HtmlTextWriter class with a specified tab string character.

HtmlTextWriter(TextWriter) HtmlTextWriter(TextWriter) HtmlTextWriter(TextWriter) HtmlTextWriter(TextWriter)

Inizializza una nuova istanza della classe HtmlTextWriter che utilizza una stringa di tabulazioni predefinita.Initializes a new instance of the HtmlTextWriter class that uses a default tab string.

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)

Parametri

writer
TextWriter TextWriter TextWriter TextWriter

Istanza TextWriter che esegue il rendering del contenuto del markup.The TextWriter instance that renders the markup content.

Esempi

Nell'esempio di codice seguente viene illustrato come utilizzare HtmlTextWriter(TextWriter) il costruttore per creare un HtmlTextWriter oggetto personalizzato StyledLabelHtmlWriter. denominato quando MyPage la classe personalizzata, derivata dalla Page classe, viene richiesta da un client browser, usa la StyledLabelHtmlWriter classe per eseguire il rendering del contenuto nel flusso di output.The following code example demonstrates how to use the HtmlTextWriter(TextWriter) constructor to create a custom HtmlTextWriter object named StyledLabelHtmlWriter. When the MyPage custom class, which is derived from the Page class, is requested by a client browser, it uses the StyledLabelHtmlWriter class to render its content to the output stream.

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

Commenti

L' HtmlTextWriter overload DefaultTabString del costruttore usa la costante quando è necessario il rientro di una riga. HtmlTextWriter(TextWriter)The HtmlTextWriter overload of the HtmlTextWriter(TextWriter) constructor uses the DefaultTabString constant when indentation of a line is necessary. Chiama l' HtmlTextWriter(TextWriter, String) overload per inizializzare la nuova istanza.It calls the HtmlTextWriter(TextWriter, String) overload to initialize the new instance.

Vedi anche

HtmlTextWriter(TextWriter, String) HtmlTextWriter(TextWriter, String) HtmlTextWriter(TextWriter, String) HtmlTextWriter(TextWriter, String)

Inizializza una nuova istanza della classe HtmlTextWriter con un carattere di stringa di tabulazioni specificato.Initializes a new instance of the HtmlTextWriter class with a specified tab string character.

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)

Parametri

writer
TextWriter TextWriter TextWriter TextWriter

Oggetto TextWriter che esegue il rendering del contenuto del markup.The TextWriter that renders the markup content.

tabString
String String String String

Stringa da utilizzare per eseguire il rendering di un rientro di riga.The string to use to render a line indentation.

Esempi

Nell'esempio di codice seguente viene illustrato come utilizzare HtmlTextWriter(TextWriter) il costruttore per creare un HtmlTextWriter oggetto personalizzato StyledLabelHtmlWriter. denominato quando MyPage la classe personalizzata, derivata dalla Page classe, viene richiesta da un client browser, usa la StyledLabelHtmlWriter classe per eseguire il rendering del contenuto nel flusso di output.The following code example demonstrates how to use the HtmlTextWriter(TextWriter) constructor to create a custom HtmlTextWriter object named StyledLabelHtmlWriter. When the MyPage custom class, which is derived from the Page class, is requested by a client browser, it uses the StyledLabelHtmlWriter class to render its content to the output stream.

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

Commenti

L' HtmlTextWriter overload tabString del costruttore utilizza quando è necessario il rientro di una riga. HtmlTextWriter(TextWriter, String)The HtmlTextWriter overload of the HtmlTextWriter(TextWriter, String) constructor uses tabString when indentation of a line is necessary. Viene chiamato il TextWriter.TextWriter(IFormatProvider) costruttore di base per inizializzare la nuova istanza.It calls the TextWriter.TextWriter(IFormatProvider) base constructor to initialize the new instance.

Vedi anche

Si applica a