HtmlTextWriter.RenderAfterTag Méthode

Définition

Écrit l'espacement ou le texte survenant après la balise de fermeture d'un élément de balisage.Writes any spacing or text that occurs after the closing tag for a markup element.

protected:
 virtual System::String ^ RenderAfterTag();
protected virtual string RenderAfterTag ();
abstract member RenderAfterTag : unit -> string
override this.RenderAfterTag : unit -> string
Protected Overridable Function RenderAfterTag () As String

Retours

String

Espacement ou texte à écrire à la suite de la balise de fermeture de l'élément.The spacing or text to write after the closing tag of the element.

Exemples

L’exemple de code suivant montre comment substituer la méthode RenderAfterTag pour déterminer si une classe dérivée de la classe HtmlTextWriter restitue un élément <label>.The following code example shows how to override the RenderAfterTag method to determine whether a class derived from the HtmlTextWriter class is rendering a <label> element. Si c’est le cas, la substitution RenderAfterTag insère la balise de fermeture d’un élément <font> immédiatement après l’élément <label>.If so, the RenderAfterTag override inserts the closing tag of a <font> element immediately after the <label> element. S’il ne s’agit pas d’un élément <label>, la méthode de base RenderAfterTag est utilisée.If it is not a <label> element, the RenderAfterTag base method is used.

// Override the RenderAfterTag method to add the
// closing tag of the Font element after the
// closing tag of a Label element has been rendered.
virtual String^ RenderAfterTag() override
{
   // Compare the TagName property value to the
   // String* label to determine whether the element to
   // be rendered is a Label. If it is a Label,
   // the closing tag of a Font element is rendered
   // after the closing tag of the Label element.
   if ( String::Compare( TagName, "label" ) == 0 )
   {
      return "</font>";
   }
   // If a Label is not being rendered, use
   // the base RenderAfterTag method.
   else
   {
      return __super::RenderAfterTag();
   }
}
// Override the RenderAfterTag method to add the 
// closing tag of the Font element after the 
// closing tag of a Label element has been rendered.
protected override string RenderAfterTag()
{
    // Compare the TagName property value to the
    // string label to determine whether the element to 
    // be rendered is a Label. If it is a Label,
    // the closing tag of a Font element is rendered
    // after the closing tag of the Label element.
    if (String.Compare(TagName, "label") == 0)
    {
        return "</font>";
    }
    // If a Label is not being rendered, use 
        // the base RenderAfterTag method.
    else
    {
        return base.RenderAfterTag();
    }
}
    ' Override the RenderAfterTag method to add the 
    ' closing tag of the Font element after the 
    ' closing tag of a Label element has been rendered.
    Protected Overrides Function RenderAfterTag() As String
        ' Compare the TagName property value to the
        ' string label to determine whether the element to 
        ' be rendered is a Label. If it is a Label,
        ' the closing tag of a Font element is rendered
        ' after the closing tag of the Label element.
        If String.Compare(TagName, "label") = 0 Then
            Return "</font>"
            ' If a Label is not being rendered, use 
            ' the base RenderAfterTag method.
        Else
            Return MyBase.RenderAfterTag()
        End If
    End Function 'RenderAfterTag
End Class

Remarques

La méthode RenderAfterTag peut être utile si vous souhaitez restituer des balises de fermeture supplémentaires après la balise d’élément.The RenderAfterTag method can be useful if you want to render additional closing tags after the element tag.

Notes pour les héritiers

L’implémentation de la classe HtmlTextWriter de la méthode RenderAfterTag() retourne null.The HtmlTextWriter class implementation of the RenderAfterTag() method returns null. Substituez RenderAfterTag() si vous souhaitez écrire du texte ou un espacement après la balise de fermeture de l’élément.Override RenderAfterTag() if you want to write text or spacing after the element closing tag.

S’applique à

Voir aussi