rendering a control to a string: why doesn't this work?

P

PJ6

Nothing comes out of this, even though I tried to observe what I thought the
HtmlTextWriter might expect for method calls.

I must be missing something simple, but what?

Private Sub TestRender()
Dim lbl As New Label
lbl.Text = "FOO"
Dim ms As New System.IO.MemoryStream
Dim tw As New System.IO.StreamWriter(ms)
Dim writer As New System.Web.UI.HtmlTextWriter(tw)
writer.BeginRender()
lbl.RenderControl(writer)
writer.EndRender()
writer.Flush()
Dim sr As New System.IO.StreamReader(ms)
Dim html As String = sr.ReadToEnd
End Sub

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top