The common way to utilize a control is to pass in properties and let the server render and display the resulting HTML. There are times when you'd want to retrieve and manipulate the rendered HTML in code before it's displayed to the user. This function allows you to pass in the control and it will return the rendered HTML as a string.
Code:Function ControlRender(ByVal objControl As Control) As String
Dim sb As New StringBuilder()
Dim sw As New System.IO.StringWriter(sb)
Dim htw As New HtmlTextWriter(sw)
objControl.RenderControl(htw)
Return sb.ToString()
End Function