HtmlTextWriter.RenderAfterTag Method

Writes any spacing or text that occurs after the closing tag for a markup element.

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

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

Return Value

The spacing or text to write after the closing tag of the element.

The RenderAfterTag method can be useful if you want to render additional closing tags after the element tag.

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

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. If so, the RenderAfterTag override inserts the closing tag of a <font> element immediately after the <label> element. 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 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(get_TagName(), "label") == 0) {
        return "</font>";
    }
        // If a Label is not being rendered, use 
        // the base RenderAfterTag method.
    else {
        return super.RenderAfterTag();
    }
} //RenderAfterTag

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: