Writes any text or spacing that occurs before the opening tag of a markup element.
Assembly: System.Web (in System.Web.dll)
The method can be useful if you want to render additional opening tags before the opening tag of the intended element.Notes to Implementers
The HtmlTextWriter class implementation of the method returns Nothing. Override if you want to write text or spacing ahead of the element opening tag.
The following code example shows how to override the method to determine whether a class that is derived from the HtmlTextWriter class is about to render a <label> element. If so, the override inserts the opening tag of a <font> element immediately before the <label> element. If it is not rendering a <label> element, the base method is used.
' Override the RenderBeforeTag method to add the ' opening tag of a Font element before the ' opening tag of any Label elements rendered by this ' custom markup writer. Protected Overrides Function RenderBeforeTag() 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 opening tag of the Font element, with a Color ' style attribute set to red, is added before ' the Label. If String.Compare(TagName, "label") = 0 Then Return "<font color=""red"">" ' If a Label is not being rendered, use ' the base RenderBeforeTag method. Else Return MyBase.RenderBeforeTag() End If End Function 'RenderBeforeTag