HtmlTextWriter.RenderAfterContent Method
Writes any text or spacing that occurs after the content and before the closing tag of the HTML element to render to the HtmlTextWriter output stream.
[Visual Basic] Protected Overridable Function RenderAfterContent() As String [C#] protected virtual string RenderAfterContent(); [C++] protected: virtual String* RenderAfterContent(); [JScript] protected function RenderAfterContent() : String;
Return Value
The spacing or text to write after the content of the HTML element. If not overridden, this method returns a null reference (Nothing in Visual Basic).
Remarks
The method can be useful if you want to inject child elements into the current HTML element.
Example
[Visual Basic, C#, C++] The following example overrides the RenderAfterContent method to determine whether the custom MyHtmlTextWriter object is rendering an HTML <label> element. If so, RenderAfterContent inserts the closing tag of an HTML <font> element immediately before the closing tag of the label. If it is not a <label> element, the base functionality of the RenderAfterContent method is used.
[Visual Basic] ' Override the RenderAfterContent method to render ' the closing tag of a font element if the ' rendered tag is a label element. <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ 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 [C#] // Override the RenderAfterContent method to render // the closing tag of a font element if the // rendered tag is a label element. [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 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(); } } [C++] // Override the RenderAfterContent method to render // the closing tag of a font element if the // rendered tag is a label element. protected: [System::Security::Permissions::PermissionSet(System::Security::Permissions::SecurityAction::Demand, Name="FullTrust")] 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 S"</font>"; } else { return __super::RenderAfterContent(); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
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