?
Solved

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

Posted on 2009-05-06
1
Medium Priority
?
748 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
wht1986 earned 2000 total points
ID: 24317579
StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
c.RenderControl(tw);
string s = sw.ToString();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

800 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