Solved

ASP.NET - Render html of a conrol in the code behind

Posted on 2009-05-06
1
739 Views
Last Modified: 2012-05-06
I'm dynamically building an html table in the code behind and need to render it into html so that I can use that also in the code behind.  I'm tyring to use the control.RenderControl() method but I'm having a hard time.

Below is what I've tried so far.

But the HtmlTextWriter must have a System.IO.TextWriter object passed to it.  When I try to create a System.IO.TextWriter object I get an error saying that I cannot create a new instance of a must inherit class.

What is the easiest way of doing what I'm trying to do here.
writer = New HtmlTextWriter()

tbl.RenderControl(writer)

Dim strTest As String = writer.ToString

Open in new window

0
Comment
Question by:josephdaviskcrm
1 Comment
 
LVL 12

Accepted Solution

by:
wht1986 earned 500 total points
Comment Utility
StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
c.RenderControl(tw);
string s = sw.ToString();
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Combine two columns 3 37
ASP.net VB.net Insert picture into SQL database 6 46
Hovering effect 9 28
Asp.net mvc 5 5 15
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now