HtmlTextWriter.RenderAfterContent メソッド

定義

コンテンツの後、およびマークアップ要素の終了タグの前に発生するテキストまたは間隔をマークアップ出力ストリームに書き込みます。

protected:
 virtual System::String ^ RenderAfterContent();
protected virtual string RenderAfterContent();
abstract member RenderAfterContent : unit -> string
override this.RenderAfterContent : unit -> string
Protected Overridable Function RenderAfterContent () As String

返品

要素の内容の後に書き込む間隔またはテキストを含む文字列。

次のコード例は、HtmlTextWriter クラスから派生したクラスのRenderAfterContent メソッドをオーバーライドして、<label>要素がレンダリングされているかどうかを判断する方法を示しています。 その場合、RenderAfterContentオーバーライドは、<label>要素の終了タグの直前に、<font>要素の終了タグを挿入します。 <label>以外の要素がレンダリングされている場合は、RenderAfterContent基本メソッドが使用されます。

// Override the RenderAfterContent method to render
// the closing tag of a font element if the
// rendered tag is a label element.

virtual String^ RenderAfterContent() override
{
   
   // Check to determine whether the element being rendered
   // is a label element. If so, render the closing tag
   // of the font element; otherwise, call the base method.
   if ( TagKey == HtmlTextWriterTag::Label )
   {
      return "</font>";
   }
   else
   {
      return __super::RenderAfterContent();
   }
}
// Override the RenderAfterContent method to render
// the closing tag of a font element if the 
// rendered tag is a label element.
protected override string RenderAfterContent()
{
    // Check to determine whether the element being rendered
    // is a label element. If so, render the closing tag
    // of the font element; otherwise, call the base method.
    if (TagKey == HtmlTextWriterTag.Label)
    {
        return "</font>";
    }
    else
    {
        return base.RenderAfterContent();
    }
}
' Override the RenderAfterContent method to render
' the closing tag of a font element if the 
' rendered tag is a label element.
Protected Overrides Function RenderAfterContent() As String
    ' Check to determine whether the element being rendered
    ' is a label element. If so, render the closing tag
    ' of the font element; otherwise, call the base method.
    If TagKey = HtmlTextWriterTag.Label Then
        Return "</font>"
    Else
        Return MyBase.RenderAfterContent()
    End If
End Function 'RenderAfterContent

注釈

RenderAfterContent メソッドは、現在のマークアップ要素に子要素を挿入する場合に便利です。

注意 (継承者)

RenderAfterContent() メソッドのHtmlTextWriter クラスの実装は、nullを返します。 要素の内容の後、終了タグの前にテキストまたは間隔を書き込む場合は、 RenderAfterContent() をオーバーライドします。

適用対象

こちらもご覧ください