Rendering a usercontrol to obtain html output in webservice

C

Choi Han Choong

Hi,
Would like to know if what I am trying to do is possible.

I have a usercontrol(ascx) that basically contains a datagrid.

I would like to save the output of this usercontrol to a file when a
webservice method is called.

I tried with the following but it does not seems to work. Nothing is
rendered.

Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

Dim uc as New UserControl
uc.LoadControl("~/Controls/Report.ascx")

uc.RenderControl( hw)

Return tw.ToString


It seems the datagrid is not init or loaded. Even if I called
uc.BindData before call to render, the grid does not seems to get init.

Is what I am trying to do possible? If not any other way to get what I
wanted to do?

Thanks.
 

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,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top