Html32TextWriter.RenderAfterContent メソッド

定義

HTML 要素の内容の後にテキストまたは空白文字を書き込みます。

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

戻り値

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

適用対象

こちらもご覧ください