Html32TextWriter.RenderAfterContent Metoda

Definicja

Zapisuje dowolny tekst lub odstępy wyświetlane po zawartości elementu HTML.

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

Zwraca

Odstępy lub tekst do zapisu po zawartości elementu HTML; w przeciwnym razie, jeśli nie ma takich informacji do renderowania, null.

Przykłady

W poniższym przykładzie kodu pokazano, jak zastąpić metodę RenderAfterContent . Każda metoda przesłonięć najpierw sprawdza, czy th element jest renderowany, a następnie używa SupportsBold metody w celu sprawdzenia, czy urządzenie żądające może wyświetlać pogrubione formatowanie. Jeśli urządzenie obsługuje formatowanie pogrubione, RenderAfterContent metoda zapisuje tag b zamykający elementu. Jeśli urządzenie nie obsługuje formatowania pogrubionego, RenderAfterContent metoda zapisuje tag font zamykający elementu.

Następnie kod sprawdza, czy h4 element jest renderowany, a następnie używa SupportsItalic właściwości w celu sprawdzenia, czy urządzenie żądające może wyświetlać formatowanie kursywy. Jeśli urządzenie obsługuje formatowanie kursywą, RenderAfterContent metoda zapisuje tag i zamykający elementu. Jeśli urządzenie nie obsługuje formatowania kursywowego, RenderAfterContent metoda zapisuje tag font zamykający elementu.

Ten przykład kodu jest częścią większego przykładu podanego Html32TextWriter dla klasy.

// 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

Dotyczy

Zobacz też