HtmlTextWriter.RenderBeforeContent HtmlTextWriter.RenderBeforeContent HtmlTextWriter.RenderBeforeContent HtmlTextWriter.RenderBeforeContent Method

定義

マークアップ要素のコンテンツの前および開始タグの後にテキストまたは空白文字を書き込みます。Writes any text or spacing before the content and after the opening tag of a markup element.

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

戻り値

要素のコンテンツの前に書き込むテキストまたは空白文字。The text or spacing to write prior to the content of the element. オーバーライドされない場合、RenderBeforeContent()null を返します。If not overridden, RenderBeforeContent() returns null.

次のコード例は、オーバーライドする方法を示します、RenderBeforeContentクラスから派生したかどうかを判断するメソッド、HtmlTextWriterクラスは、表示しようとする、<label>要素。The following code example shows how to override the RenderBeforeContent method to determine whether a class derived from the HtmlTextWriter class is about to render a <label> element. そうである場合、RenderBeforeContent上書き挿入の開始タグ、<font>要素の開始タグの直後後、<label>要素。If so, the RenderBeforeContent override inserts the opening tag of a <font> element immediately after the opening tag of the <label> element. ない場合、<label>要素、RenderBeforeContent基本メソッドを使用します。If it is not a <label> element, the RenderBeforeContent base method is used.

// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.

virtual String^ RenderBeforeContent() override
{
   
   // Check to determine whether the element being rendered
   // is a label element. If so, render the opening tag
   // of the font element; otherwise, call the base method.
   if ( TagKey == HtmlTextWriterTag::Label )
   {
      return "<font color=\"red\">";
   }
   else
   {
      return __super::RenderBeforeContent();
   }
}


// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
protected override string RenderBeforeContent()
{
    // Check to determine whether the element being rendered
    // is a label element. If so, render the opening tag
    // of the font element; otherwise, call the base method.
    if (TagKey == HtmlTextWriterTag.Label)
    {
        return "<font color=\"red\">";
    }
    else
    {
        return base.RenderBeforeContent();
    }
}
' Override the RenderBeforeContent method to write
' a font element that applies red to the text in a Label element.
Protected Overrides Function RenderBeforeContent() As String
    ' Check to determine whether the element being rendered
    ' is a label element. If so, render the opening tag
    ' of the font element; otherwise, call the base method.
    If TagKey = HtmlTextWriterTag.Label Then
        Return "<font color=""red"">"
    Else
        Return MyBase.RenderBeforeContent()
    End If
End Function 'RenderBeforeContent

注釈

RenderBeforeContentメソッドは内部マークアップの前に、現在のマークアップ要素に子要素を挿入する場合に便利にできます。The RenderBeforeContent method can be useful if you want to insert child elements into the current markup element before the inner markup.

注意 (継承者)

HtmlTextWriterのクラスの実装、RenderBeforeContent()メソッドを返します。nullします。The HtmlTextWriter class implementation of the RenderBeforeContent() method returns null. オーバーライドRenderBeforeContent()テキストまたは空白文字の開始タグの後、前の要素の内容を記述するかどうか。Override RenderBeforeContent() if you want to write text or spacing after the opening tag but ahead of the element content.

適用対象

こちらもご覧ください