This documentation is archived and is not being maintained.

HtmlTextWriter.RenderAfterTag Method

Writes any spacing or text that occurs after an HTML element's closing tag.

[Visual Basic]
Protected Overridable Function RenderAfterTag() As String
[C#]
protected virtual string RenderAfterTag();
[C++]
protected: virtual String* RenderAfterTag();
[JScript]
protected function RenderAfterTag() : String;

Return Value

The spacing or text to write after the closing tag of the HTML element. If not overridden, this method returns a null reference (Nothing in Visual Basic).

Example

[Visual Basic, C#, C++] The following example overrides the RenderAfterTag method to determine whether the custom MyHtmlTextWriter object is rendering an HTML <label> element. If so, RenderAfterTag inserts the closing tag of an HTML <font> element immediately after the label. If it is not a <label> element, the base functionality of the RenderAfterTag method is used.

[Visual Basic] 
' 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 

[C#] 
// 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();
   }        
}

[C++] 
// 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(TagName, S"label") == 0) {
      return S"</font>";
   }
   // If a Label is not being rendered, use
   // the base RenderAfterTag method.
   else {
      return __super::RenderAfterTag();
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HtmlTextWriter Class | HtmlTextWriter Members | System.Web.UI Namespace

Show: