Html32TextWriter.RenderAfterContent Metoda

Definice

Zapíše veškerý text nebo mezery, které se zobrazí za obsahem elementu HTML.

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

Návraty

Mezery nebo text, který se má psát za obsahem html elementu; v opačném případě, pokud neexistuje žádná taková informace k vykreslení, null.

Příklady

Následující příklad kódu ukazuje, jak přepsat metodu RenderAfterContent . Každá přepsaná metoda nejprve zkontroluje, jestli th se prvek vykresluje, a pak pomocí SupportsBold metody zkontroluje, jestli může žádající zařízení zobrazit tučné formátování. Pokud zařízení podporuje formátování tučným písmem RenderAfterContent , metoda zapíše uzavírací značku elementu b . Pokud zařízení nepodporuje tučné formátování, RenderAfterContent metoda zapíše uzavírací značku font prvku.

Dále kód zkontroluje, jestli h4 se prvek vykresluje, a pak pomocí SupportsItalic vlastnosti zkontroluje, jestli může žádající zařízení zobrazit kurzívu. Pokud zařízení podporuje formátování kurzívou, RenderAfterContent metoda zapíše uzavírací značku elementu i . Pokud zařízení nepodporuje formátování kurzívou, RenderAfterContent metoda zapíše uzavírací značku elementu font .

Tento příklad kódu je součástí většího příkladu Html32TextWriter pro třídu .

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

Platí pro

Viz také