Share via


Html32TextWriter.RenderAfterContent 方法

定義

寫入任何出現在 HTML 項目內容之後的文字或間距。

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

傳回

要在 HTML 項目內容之後寫入的間距或文字,如果沒有這樣的資訊可以呈現,則為 null

範例

下列程式碼範例示範如何覆寫 RenderAfterContent 方法。 每個覆寫的方法都會先檢查項目是否 th 正在轉譯,然後使用 SupportsBold 方法來檢查要求裝置是否可以顯示粗體格式。 如果裝置支援粗體格式設定, RenderAfterContent 方法會寫入專案的結束記號 b 。 如果裝置不支援粗體格式設定, RenderAfterContent 方法會寫入專案的結束記號 font

接下來,程式碼會檢查項目是否 h4 正在轉譯,然後使用 SupportsItalic 屬性來檢查要求裝置是否可以顯示斜體格式。 如果裝置支援斜體格式設定, RenderAfterContent 方法會寫入專案的結束記號 i 。 如果裝置不支援斜體格式設定, RenderAfterContent 方法會寫入專案的結束記號 font

此程式碼範例是提供給 類別之較大範例的 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

適用於

另請參閱