Export (0) Print
Expand All

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()

Return Value

Type: System.String
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 null. 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. 
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. 
        return base.RenderAfterTag();

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft