次の方法で共有


HtmlTextWriter.RenderAfterContent メソッド

マークアップ要素の内容の後および終了タグの前に出現するテキストまたは空白文字をマークアップの出力ストリームに書き込みます。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Protected Overridable Function RenderAfterContent As String
'使用
Dim returnValue As String

returnValue = Me.RenderAfterContent
protected virtual string RenderAfterContent ()
protected:
virtual String^ RenderAfterContent ()
protected String RenderAfterContent ()
protected function RenderAfterContent () : String
適用できません。

戻り値

要素の内容の後に書き込む空白文字またはテキストを格納している文字列。

解説

RenderAfterContent メソッドは、子要素を現在のマークアップ要素に挿入する場合に役立ちます。

継承元へのメモ : HtmlTextWriter クラスで実装されている RenderAfterContent メソッドは、null 参照 (Visual Basic では Nothing) を返します。要素の内容の後、終了タグの前にテキストまたは空白文字を書き込む場合は、RenderAfterContent をオーバーライドします。

使用例

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

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 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 (get_TagKey().Equals(HtmlTextWriterTag.Label)) {
        return "</font>";
    }
    else {
        return super.RenderAfterContent();
    }
} //RenderAfterContent

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

HtmlTextWriter クラス
HtmlTextWriter メンバ
System.Web.UI 名前空間
TextWriter