HtmlTextWriter.RenderAfterTag HtmlTextWriter.RenderAfterTag HtmlTextWriter.RenderAfterTag HtmlTextWriter.RenderAfterTag Method

定義

寫入標記項目的結尾標記之後所發生的任何間距或文字。Writes any spacing or text that occurs after the closing tag for a markup element.

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

傳回

要在項目的結尾標記之後寫入的間距或文字。The spacing or text to write after the closing tag of the element.

範例

下列程式碼範例示範如何覆寫RenderAfterTag方法,以判斷衍生HtmlTextWriter自類別的類別是否正在呈現<label>專案。The following code example shows how to override the RenderAfterTag method to determine whether a class derived from the HtmlTextWriter class is rendering a <label> element. 若是如此, RenderAfterTag覆寫就會將<font>元素的結束記號插入緊接在<label>專案之後。If so, the RenderAfterTag override inserts the closing tag of a <font> element immediately after the <label> element. 如果不<label>是元素RenderAfterTag ,則會使用基底方法。If it is not a <label> element, the RenderAfterTag base method is used.

// Override the RenderAfterTag method to add the
// closing tag of the Font element after the
// closing tag of a Label element has been rendered.
virtual String^ RenderAfterTag() 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 closing tag of a Font element is rendered
   // after the closing tag of the Label element.
   if ( String::Compare( TagName, "label" ) == 0 )
   {
      return "</font>";
   }
   // If a Label is not being rendered, use
   // the base RenderAfterTag method.
   else
   {
      return __super::RenderAfterTag();
   }
}
// Override the RenderAfterTag method to add the 
// closing tag of the Font element after the 
// closing tag of a Label element has been rendered.
protected override string RenderAfterTag()
{
    // 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 closing tag of a Font element is rendered
    // after the closing tag of the Label element.
    if (String.Compare(TagName, "label") == 0)
    {
        return "</font>";
    }
    // If a Label is not being rendered, use 
        // the base RenderAfterTag method.
    else
    {
        return base.RenderAfterTag();
    }
}
    ' Override the RenderAfterTag method to add the 
    ' closing tag of the Font element after the 
    ' closing tag of a Label element has been rendered.
    Protected Overrides Function RenderAfterTag() 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 closing tag of a Font element is rendered
        ' after the closing tag of the Label element.
        If String.Compare(TagName, "label") = 0 Then
            Return "</font>"
            ' If a Label is not being rendered, use 
            ' the base RenderAfterTag method.
        Else
            Return MyBase.RenderAfterTag()
        End If
    End Function 'RenderAfterTag
End Class 'htwFour 

備註

如果您想要在專案標記之後呈現其他結束記號,方法可能很有用。RenderAfterTagThe RenderAfterTag method can be useful if you want to render additional closing tags after the element tag.

給繼承者的注意事項

RenderAfterTag() 方法nullHtmlTextWriter類別實會傳回。The HtmlTextWriter class implementation of the RenderAfterTag() method returns null. 如果RenderAfterTag()您想要在元素結束記號之後寫入文字或間距,請覆寫。Override RenderAfterTag() if you want to write text or spacing after the element closing tag.

適用於

另請參閱