User800858375 posted
Hi everyone,
It is possible to grab the HTML output from a custom control by doing the following:
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htmlTw = new HtmlTextWriter(sw);
myCustomControl.RenderControl(htmlTw);
string controlsHTML = sb.ToString();
I was wondering how you could do the same of a User control and its entire contents. Take an example that a user control contains some standard HTML markup as well as a GridView control and a Button control. The GridView would normally be data bound in the
Page_Load event.
If you use LoadControl("target.ascx") and grab the rendered contents:
A > Only the standard HTML markup is retrieved
B > The GridView does not get data bound
How can you bind the grid view, and then retrieve the entire contents of the user control?
Thanks again,
Ad