HtmlTextWriter.RenderAfterContent 方法

定义

写入在标记元素的内容之后、结束标记之前出现的任何文本或间距以呈现给标记输出流。Writes any text or spacing that occurs after the content and before the closing tag of the markup element to the markup output stream.

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

返回

包含要在元素内容后面写入的间距或文本的字符串。A string that contains the spacing or text to write after the content of the element.

示例

下面的代码示例演示如何重写RenderAfterContent HtmlTextWriter从类派生的类中的方法,以确定是否正在<label>呈现某个元素。The following code example shows how to override the RenderAfterContent method in a class derived from the HtmlTextWriter class to determine whether a <label> element is being rendered. 如果是这样, RenderAfterContent则重写会在<label>元素的<font>结束标记之前插入元素的结束标记。If so, the RenderAfterContent override inserts the closing tag of a <font> element immediately before the closing tag of the <label> element. 如果呈现的元素<label>不是RenderAfterContent ,则使用基方法。If an element other than <label> is being rendered, the RenderAfterContent base method is used.

// Override the RenderAfterContent method to render
// the closing tag of a font element if the
// rendered tag is a label element.

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

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

注解

如果RenderAfterContent要在当前标记元素中插入子元素,则此方法非常有用。The RenderAfterContent method can be useful if you want to insert child elements into the current markup element.

继承者说明

RenderAfterContent() null方法的HtmlTextWriter类实现返回。The HtmlTextWriter class implementation of the RenderAfterContent() method returns null. 如果RenderAfterContent()要在元素内容之后、结束标记之前写入文本或间距,则重写。Override RenderAfterContent() if you want to write text or spacing after the element content but before the closing tag.

适用于

另请参阅