HtmlTextWriter.RenderAfterContent Method

Writes any text or spacing that occurs after the content and before the closing tag of the markup element to the markup output stream.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

protected:
virtual String^ RenderAfterContent ()
protected String RenderAfterContent ()
protected function RenderAfterContent () : String
Not applicable.

Return Value

A string that contains the spacing or text to write after the content of the element.

The RenderAfterContent method can be useful if you want to insert child elements into the current markup element.

Notes to Inheritors: The HtmlTextWriter class implementation of the RenderAfterContent method returns a null reference (Nothing in Visual Basic). Override RenderAfterContent if you want to write text or spacing after the element content but before the closing tag.

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. If so, the RenderAfterContent override inserts the closing tag of a <font> element immediately before the closing tag of the <label> element. 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 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 (get_TagKey().Equals(HtmlTextWriterTag.Label)) {
        return "</font>";
    }
    else {
        return super.RenderAfterContent();
    }
} //RenderAfterContent

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: