Html32TextWriter.RenderAfterContent 方法

定义

写入在 HTML 元素内容之后出现的所有文本或间距。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

返回

String

要在 HTML 元素内容之后写入的间距或文本;如果没有此类信息要呈现,则为 nullThe spacing or text to write after the content of the HTML element; otherwise, if there is no such information to render, null.

示例

下面的代码示例演示如何重写 RenderAfterContent 方法。The following code example demonstrates how to override the RenderAfterContent method. 每个重写的方法首先检查是否 th 正在呈现某个元素,然后使用 SupportsBold 方法检查请求设备是否可以显示粗体格式。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. 如果设备支持粗体格式,则 RenderAfterContent 方法会写入元素的结束标记 bIf the device supports bold formatting, the RenderAfterContent method writes the closing tag of a b element. 如果设备不支持粗体格式,则方法会 RenderAfterContent 写入元素的结束标记 fontIf the device does not support bold formatting, the RenderAfterContent method writes the closing tag of a font element.

接下来,代码检查是否 h4 正在呈现某个元素,然后使用 SupportsItalic 属性检查请求设备是否可以显示斜体格式。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. 如果设备支持斜体格式,则 RenderAfterContent 方法会写入元素的结束标记 iIf the device supports italic formatting, the RenderAfterContent method writes the closing tag of an i element. 如果设备不支持斜体格式,则方法会 RenderAfterContent 写入元素的结束标记 fontIf the device does not support italic formatting, the RenderAfterContent method writes the closing tag of a font element.

此代码示例是为类提供的更大示例的一部分 Html32TextWriterThis 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

适用于

另请参阅