HtmlTextWriter.RenderBeforeTag メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HtmlTextWriter.RenderBeforeTag メソッドの意味・解説 

HtmlTextWriter.RenderBeforeTag メソッド

マークアップ要素開始タグ前に出現するテキストまたは空白文字書き込みます

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

解説解説

RenderBeforeTag メソッドは、対象とする要素開始タグ前に開始タグ追加して出力する場合に便利です。

実装時の注意 HtmlTextWriter クラス実装されている RenderBeforeTag メソッドは、null 参照 (Visual Basic では Nothing) を返します要素開始タグ前にテキストまたは空白文字書き込む場合は、RenderBeforeTagオーバーライドます。

使用例使用例

RenderBeforeTag メソッドオーバーライドして、HtmlTextWriter クラスから派生したクラス<label> 要素出力するかどうか確認する方法次のコード例示します出力する場合は、RenderBeforeTag オーバーライド<label> 要素直前に、<font> 要素開始タグ挿入します<label> 要素出力しない場合は、RenderBeforeTag 基本メソッド使用されます。

' Override the RenderBeforeTag method to add the 
' opening tag of a Font element before the 
' opening tag of any Label elements rendered by this 
' custom markup writer. 
Protected Overrides Function
 RenderBeforeTag() As String
    ' Compare the TagName property value to the
    ' string label to determine whether the element to 
    ' be rendered is a Label. If it is a Label,
    ' the opening tag of the Font element, with a Color
    ' style attribute set to red, is added before
    ' the Label.
    If String.Compare(TagName, "label")
 = 0 Then
        Return "<font color=""red"">"
        ' If a Label is not being rendered, use 
        ' the base RenderBeforeTag method.
    Else
        Return MyBase.RenderBeforeTag()
    End If
End Function 'RenderBeforeTag
// Override the RenderBeforeTag method to add the 
// opening tag of a Font element before the 
// opening tag of any Label elements rendered by this 
// custom markup writer. 
protected override string RenderBeforeTag()
{
    // Compare the TagName property value to the
    // string label to determine whether the element to 
    // be rendered is a Label. If it is a Label,
    // the opening tag of the Font element, with a Color
    // style attribute set to red, is added before
    // the Label.
    if (String.Compare(TagName, "label") == 0)
    {
        return "<font color=\"red\">";
    }
    // If a Label is not being rendered, use 
        // the base RenderBeforeTag method.
    else
    {
        return base.RenderBeforeTag();
    }
}
// Override the RenderBeforeTag method to add the
// opening tag of a Font element before the
// opening tag of any Label elements rendered by this
// custom markup writer.
virtual String^ RenderBeforeTag() override
{
   // Compare the TagName property value to the
   // String* label to determine whether the element to
   // be rendered is a Label. If it is a Label,
   // the opening tag of the Font element, with a Color
   // style attribute set to red, is added before
   // the Label.
   if ( String::Compare( TagName, "label" ) == 0 )
   {
      return "<font color=\"red\">";
   }
   // If a Label is not being rendered, use
   // the base RenderBeforeTag method.
   else
   {
      return __super::RenderBeforeTag();
   }
}
// Override the RenderBeforeTag method to add the 
// opening tag of a Font element before the 
// opening tag of any Label elements rendered by this 
// custom markup writer. 
protected String RenderBeforeTag()
{
    // Compare the TagName property value to the
    // string label to determine whether the element to 
    // be rendered is a Label. If it is a Label,
    // the opening tag of the Font element, with a Color
    // style attribute set to red, is added before
    // the Label.
    if (String.Compare(get_TagName(), "label") == 0)
 {
        return "<font color=\"red\">";
    }
        // If a Label is not being rendered, use 
        // the base RenderBeforeTag method.
    else  {
        return super.RenderBeforeTag();
    }
} //RenderBeforeTag
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlTextWriter クラス
HtmlTextWriter メンバ
System.Web.UI 名前空間
TextWriter


このページでは「.NET Framework クラス ライブラリ リファレンス」からHtmlTextWriter.RenderBeforeTag メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHtmlTextWriter.RenderBeforeTag メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHtmlTextWriter.RenderBeforeTag メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HtmlTextWriter.RenderBeforeTag メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HtmlTextWriter.RenderBeforeTag メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS