How to get rendered text from controls or text contained by a custom control in ASP.NET?
<p>I am creating a control that will display text from a database field.  If the field does not contain any data, I would like to provide it default content to use, which I want to set to the DB field and render to the page.  Not a terribly complex thing, I'm just having trouble getting the contents of the tag.</p>

<p>Example:</p>

<pre><code>&lt;custom:foo runat="server"&gt;this is the default content&lt;/custom:foo&gt;
</code></pre>

<p>I would like to be able to grab any markup between the custom:foo tags and render that to a string that I can store in the DB field.</p>

<p>I know the easy way to do this is to just create a DefaultContent property and set it that way, but I like the flexibility to place more than just text inside the control and render it.</p>

<p>I've tried using Me.RenderChildren into an HtmlTextWriter and all I get from the above example is <code>"&lt;span&gt;&lt;/span&gt;"</code></p>

<pre><code>        Dim Builder As New StringBuilder()
        Using Writer As New StringWriter(Builder)
            Using HtmlWriter As New HtmlTextWriter(Writer)
                Me.RenderChildren(HtmlWriter)
            End Using
        End Using
        Return Builder.ToString()
</code></pre>

<p>Has anyone had any success with this sort of thing?</p>
