HtmlTextWriter.RenderBeforeTag HtmlTextWriter.RenderBeforeTag HtmlTextWriter.RenderBeforeTag HtmlTextWriter.RenderBeforeTag Method

定義

マークアップ要素の開始タグの前に出現するテキストまたは空白文字を書き込みます。Writes any text or spacing that occurs before the opening tag of a markup element.

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

戻り値

マークアップ要素の開始タグの前に書き込むテキストまたは空白文字。The text or spacing to write before the markup element opening tag. オーバーライドされない場合は nullIf not overridden, null.

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

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

注釈

RenderBeforeTagメソッドは目的の要素の開始タグの前に、追加の開始タグをレンダリングする役に立ちます。The RenderBeforeTag method can be useful if you want to render additional opening tags before the opening tag of the intended element.

注意 (継承者)

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

適用対象

こちらもご覧ください