Sdílet prostřednictvím


Html32TextWriter.RenderAfterContent Metoda

Definice

Zapíše jakýkoli 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 pro zápis za obsah elementu HTML; v opačném případě, pokud neexistují žádné takové informace, které by bylo třeba vykreslit, 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 vykresluje prvek, a pak pomocí SupportsBold této metody zkontroluje, jestli může žádající zařízení zobrazit tučné formátování. Pokud zařízení podporuje tučné formátování, RenderAfterContent metoda zapíše pravou značku elementu b . Pokud zařízení nepodporuje tučné formátování, RenderAfterContent metoda zapíše pravou značku elementu font .

Dále kód zkontroluje, jestli h4 se vykresluje prvek, 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 pravou značku elementu i . Pokud zařízení nepodporuje formátování kurzívou, RenderAfterContent metoda zapíše pravou značku elementu font .

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

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