Compartilhar via


Html32TextWriter.RenderAfterContent Método

Definição

Grava qualquer texto ou espaçamento que aparece depois do conteúdo do elemento HTML.

protected:
 override System::String ^ RenderAfterContent();
protected override string RenderAfterContent ();
override this.RenderAfterContent : unit -> string
Protected Overrides Function RenderAfterContent () As String

Retornos

String

O espaçamento ou o texto a ser gravado após o conteúdo do elemento HTML; caso contrário, se não houver nenhuma dessas informações para renderizar, null.

Exemplos

O exemplo de código a seguir demonstra como substituir o RenderAfterContent método. Cada método substituído primeiro verifica se um th elemento está sendo renderizado e, em seguida, usa o SupportsBold método para verificar se o dispositivo solicitante pode exibir formatação em negrito. Se o dispositivo der suporte à formatação em negrito, o RenderAfterContent método gravará a marca de fechamento de um b elemento. Se o dispositivo não oferecer suporte à formatação em negrito, o método gravará RenderAfterContent a marca de fechamento de um font elemento.

Em seguida, o código verifica se um h4 elemento está sendo renderizado e usa a SupportsItalic propriedade para verificar se o dispositivo solicitante pode exibir a formatação itálica. Se o dispositivo der suporte à formatação itálica, o RenderAfterContent método gravará a marca de fechamento de um i elemento. Se o dispositivo não oferecer suporte à formatação itálica, o RenderAfterContent método gravará a marca de fechamento de um font elemento.

Este exemplo de código faz parte de um exemplo maior fornecido para a Html32TextWriter classe.

// Override the RenderAfterContent method to close
// styles opened during the call to the RenderBeforeContent
// method.
protected override string RenderAfterContent()
{
    // Check whether the element being rendered is a <th> element.
    // If so, and the requesting device supports bold formatting,
    // render the closing tag of the <b> element. If not,
    // render the closing tag of the <font> element.
    if (TagKey == HtmlTextWriterTag.Th)
    {
        if (SupportsBold)
            return "</b>";
        else
            return "</font>";
    }

    // Check whether the element being rendered is an <H4>.
    // element. If so, and the requesting device supports italic
    // formatting, render the closing tag of the <i> element.
    // If not, render the closing tag of the <font> element.
    if (TagKey == HtmlTextWriterTag.H4)
    {
        if (SupportsItalic)
            return "</i>";
        else
            return "</font>";
    }
    // Call the base method
    return base.RenderAfterContent();
}
' Override the RenderAfterContent method to close
' styles opened during the call to the RenderBeforeContent
' method.
Protected Overrides Function RenderAfterContent() As String

    ' Check whether the element being rendered is a <th> element.
    ' If so, and the requesting device supports bold formatting,
    ' render the closing tag of the <b> element. If not,
    ' render the closing tag of the <font> element.
    If TagKey = HtmlTextWriterTag.Th Then
        If SupportsBold Then
            Return "</b>"
        Else
            Return "</font>"
        End If
    End If

    ' Check whether the element being rendered is an <H4>.
    ' element. If so, and the requesting device supports italic
    ' formatting, render the closing tag of the <i> element.
    ' If not, render the closing tag of the <font> element.
    If TagKey = HtmlTextWriterTag.H4 Then
        If (SupportsItalic) Then
            Return "</i>"
        Else
            Return "</font>"
        End If
    End If
    ' Call the base method.
    Return MyBase.RenderAfterContent()
End Function

Aplica-se a

Confira também