HtmlTextWriter Constructeurs
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Initialise une nouvelle instance de la classe HtmlTextWriter.
Surcharges
| Nom | Description |
|---|---|
| HtmlTextWriter(TextWriter) |
Initialise une nouvelle instance de la HtmlTextWriter classe qui utilise une chaîne d’onglet par défaut. |
| HtmlTextWriter(TextWriter, String) |
Initialise une nouvelle instance de la HtmlTextWriter classe avec un caractère de chaîne d’onglet spécifié. |
HtmlTextWriter(TextWriter)
Initialise une nouvelle instance de la HtmlTextWriter classe qui utilise une chaîne d’onglet par défaut.
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)
Paramètres
- writer
- TextWriter
Instance TextWriter qui affiche le contenu du balisage.
Exemples
L’exemple de code suivant montre comment utiliser le HtmlTextWriter(TextWriter) constructeur pour créer un objet personnalisé HtmlTextWriter nommé StyledLabelHtmlWriter. Lorsque la MyPage classe personnalisée, dérivée de la Page classe, est demandée par un navigateur client, elle utilise la StyledLabelHtmlWriter classe pour afficher son contenu dans le flux de sortie.
// 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
Remarques
La HtmlTextWriter surcharge du HtmlTextWriter(TextWriter) constructeur utilise la DefaultTabString constante lorsque la mise en retrait d’une ligne est nécessaire. Il appelle la HtmlTextWriter(TextWriter, String) surcharge pour initialiser la nouvelle instance.
Voir aussi
S’applique à
HtmlTextWriter(TextWriter, String)
Initialise une nouvelle instance de la HtmlTextWriter classe avec un caractère de chaîne d’onglet spécifié.
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)
Paramètres
- writer
- TextWriter
Qui TextWriter restitue le contenu du balisage.
- tabString
- String
Chaîne à utiliser pour afficher une mise en retrait de ligne.
Exemples
L’exemple de code suivant montre comment utiliser le HtmlTextWriter(TextWriter) constructeur pour créer un objet personnalisé HtmlTextWriter nommé StyledLabelHtmlWriter. Lorsque la MyPage classe personnalisée, dérivée de la Page classe, est demandée par un navigateur client, elle utilise la StyledLabelHtmlWriter classe pour afficher son contenu dans le flux de sortie.
// 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
Remarques
La HtmlTextWriter surcharge du HtmlTextWriter(TextWriter, String) constructeur utilise tabString lorsque la mise en retrait d’une ligne est nécessaire. Il appelle le TextWriter.TextWriter(IFormatProvider) constructeur de base pour initialiser la nouvelle instance.