HtmlTextWriter.TagName HtmlTextWriter.TagName HtmlTextWriter.TagName HtmlTextWriter.TagName Property

定義

レンダリングされるマークアップ要素のタグ名を取得または設定します。Gets or sets the tag name of the markup element being rendered.

protected:
 property System::String ^ TagName { System::String ^ get(); void set(System::String ^ value); };
protected string TagName { get; set; }
member this.TagName : string with get, set
Protected Property TagName As String

プロパティ値

出力されるマークアップ要素のタグ名。The tag name of the markup element being rendered.

次のコード例のオーバーライドされたバージョンを示します、RenderBeforeTagから派生したクラスのメソッド、HtmlTextWriterクラス。The following code example demonstrates an overridden version of the RenderBeforeTag method in a class that derives from the HtmlTextWriter class. コード例は、レンダリングする要素がかどうかを確認します。、<label>要素を呼び出すことによって、String.Compareメソッドを渡す、、TagNameプロパティの値と、文字列"label"、パラメーターの引数として。The code example checks whether the element to render is a <label> element by calling the String.Compare method, and then passing the TagName property value and a string, "label", as the parameter arguments. 場合、<label>要素のレンダリングの開始タグ、<font>要素で、color属性に設定red、前にレンダリング、<label>の開始タグの要素。If a <label> element is about to be rendered, the opening tag of a <font> element, with a color attribute set to red, is rendered before the <label> element's opening tag. レンダリングする要素がない場合、<label>要素では、基底クラスのバージョンのRenderBeforeTagメソッドが呼び出されます。If the element to render is not a <label> element, the base class's version of the RenderBeforeTag method is called.

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

注釈

TagNameはから継承するクラスにのみ使用するプロパティ、HtmlTextWriterクラス。The TagName property is of use only to classes that inherit from the HtmlTextWriter class. 読み取りまたは設定する必要があります、TagNameプロパティでのみRenderBeginTagメソッドの呼び出しです。 これは、一貫性のある値に設定されている唯一の時間。You should read or set the TagName property only in RenderBeginTag method calls; this is the only time it is set to a consistent value.

適用対象

こちらもご覧ください