Condividi tramite


Html32TextWriter.RenderAfterContent Metodo

Definizione

Scrive qualsiasi testo o spaziatura visualizzato dopo il contenuto dell'elemento HTML.

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

Restituisce

Spaziatura o testo da scrivere dopo il contenuto dell'elemento HTML; in caso contrario, se non sono presenti informazioni di questo tipo per il rendering, null.

Esempio

Nell'esempio di codice seguente viene illustrato come eseguire l'override del RenderAfterContent metodo . Ogni metodo sottoposto a override controlla innanzitutto se viene eseguito il rendering di un th elemento e quindi usa il SupportsBold metodo per verificare se il dispositivo richiedente può visualizzare la formattazione in grassetto. Se il dispositivo supporta la formattazione in grassetto, il RenderAfterContent metodo scrive il tag di chiusura di un b elemento. Se il dispositivo non supporta la formattazione in grassetto, il RenderAfterContent metodo scrive il tag di chiusura di un font elemento.

Il codice controlla quindi se viene eseguito il rendering di un h4 elemento e quindi usa la SupportsItalic proprietà per verificare se il dispositivo richiedente può visualizzare la formattazione corsiva. Se il dispositivo supporta la formattazione corsiva, il RenderAfterContent metodo scrive il tag di chiusura di un i elemento. Se il dispositivo non supporta la formattazione corsiva, il RenderAfterContent metodo scrive il tag di chiusura di un font elemento.

Questo esempio di codice fa parte di un esempio più ampio fornito per la 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

Si applica a

Vedi anche