Html32TextWriter.RenderAfterContent Metodo

Definizione

Scrive eventuale testo o spaziatura disponibile 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

String

Spaziatura o testo da scrivere dopo il contenuto dell'elemento HTML. In caso contrario, se non esistono informazioni di questo tipo di cui eseguire il rendering, null.

Esempio

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

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

Questo esempio di codice fa parte di un esempio più grande 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