myname
myname

Reputation:

rendering a user control to a string

I'm using the technique described here to render a User Control to a string and it all works fine when the control contains just plain HTML, but when I try adding some server controls to the UC (like asp:button) I get the following error when calling server.execute:

"Error executing child request for handler 'System.Web.UI.Page'."

any ideas why/how to fix it? thanks.

Upvotes: 1

Views: 395

Answers (2)

myname
myname

Reputation:

The problem was that the UC should have been added to the form's control collection, not the page's.

Upvotes: 1

Colin
Colin

Reputation: 10638

Could you try to include a call to EnsureChildControls() before to render to a string. This way you force the page to render the entire control tree first.

Upvotes: 0

Related Questions