El siguiente codigo puede que a mas de uno le sea de utilidad. Este ejemplo usa un datagrid para mostrar los datos. Tambien aplica a los controles de asp net 2.0.
El ejemplo extrae el codigo html que asp net genera.
Código:
Dim cnn As New SqlConnection(AppSettings("ActivitiesConnection"))
Dim adap As New SqlDataAdapter("select * from actividades", cnn)
Dim dtable As New DataTable
adap.Fill(dtable)
Me.DataGrid1.DataSource = dtable
Me.DataGrid1.DataBind()
Dim str As String
Dim strbuild As System.Text.StringBuilder
Dim strWriter, strWriter2 As System.IO.StringWriter
strWriter = New System.IO.StringWriter
strWriter2 = New System.IO.StringWriter
Dim html As New System.Web.UI.HtmlTextWriter(strWriter)
'me.datos = control que contiene todo el html que se quiere obtener
Me.DataGrid1.RenderControl(html)
strWriter2 = html.InnerWriter
strbuild = strWriter2.GetStringBuilder()
'str contiene todo el html del control
str = strbuild.ToString()
en donde la variable str se almacena el string del codigo html del datagrid que es mostrado en el cliente.
Salu2