Html32TextWriter.RenderAfterContent Method

Definition

Writes any text or spacing that appears after the content of the HTML element.

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

Returns

The spacing or text to write after the content of the HTML element; otherwise, if there is no such information to render, null.

Examples

The following code example demonstrates how to override the RenderAfterContent method. Each overridden method first checks whether a th element is being rendered, and then uses the SupportsBold method to check whether the requesting device can display bold formatting. If the device supports bold formatting, the RenderAfterContent method writes the closing tag of a b element. If the device does not support bold formatting, the RenderAfterContent method writes the closing tag of a font element.

Next, the code checks whether an h4 element is being rendered, and then uses the SupportsItalic property to check whether the requesting device can display italic formatting. If the device supports italic formatting, the RenderAfterContent method writes the closing tag of an i element. If the device does not support italic formatting, the RenderAfterContent method writes the closing tag of a font element.

This code example is part of a larger example provided for the Html32TextWriter class.

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

Applies to

See also