Want to return a System.Web.UI.WebControls.Table as HTML to be sent in the body of an HTML email


i am writing a basket on several pages using a panel in the aspx and a sub that builds/populates the table and adds it to the panel. this is fine.
i now need to send the same table in an HTML email, but want to use the same method.

ive tried returning the table as a string, but this just produces 'System.Web.UI.WebControls.Table'

any ideas?
LVL 11
Who is Participating?
anoyesConnect With a Mentor Commented:
You can use the RenderControl method of the table to write the contents to HTML.

Dim sb As New System.Text.StringBuilder
Dim ht As New System.Web.UI.HtmlTextWriter(New System.IO.StringWriter(sb))
Dim html As String = ht.InnerWriter.ToString

Open in new window

glumlunAuthor Commented:
thankyou very much, perfect sollution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.