another try:
during the oninit I add the control in the page, then I render this control
only later, but in this case the error is:
Control 'ctl00_MainContent_MyControl_FormView1' of type 'FormView' must be
placed inside a form tag with runat=server.
The rendering process of the formview verify that the control is correctly
created in a page.
Can I create a page in memory???
"Jéjé" <willgart_A_@hotmail_A_.com> wrote in message
news:ee****************@TK2MSFTNGP14.phx.gbl...
allready tried, and this cause another error
which is:
The RegisterRequiresViewStateEncryption() method needs to be called before
or during Page_PreRender.
when I try to add the control in the placeholder.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OV**************@TK2MSFTNGP12.phx.gbl... This might work, not sure. Place the control on the page, call
RenderControl() then remove it :)
somePlaceHolder.Controls.Add(ctl);
ctl.DataBind();
ctl.RenderControl(htmlTExtWriter);
somePlaceHolder.Controls.Remove(ctl);
where somePlaceHolder is just an <asp:placeholder control inside a form.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Jéjé" <willgart_A_@hotmail_A_.com> wrote in message
news:Ot**************@TK2MSFTNGP14.phx.gbl... Hi,
I want to dynamically load an ASCX control which contain a formview.
And I want to render the result into a string.
but I receive some errors like:
Control 'FormView1' of type 'FormView' must be placed inside a form tag
with runat=server
StringBuilder stringBuilder = new StringBuilder();
StringWriter stringWriter;
HtmlTextWriter htmlTextWriter;
stringWriter = new StringWriter(stringBuilder);
htmlTextWriter = new HtmlTextWriter(stringWriter);
ctl = Page.LoadControl("~/controls/Overview.ascx");
.... some commands here ....
ctl.DataBind();
ctl.RenderControl(htmlTextWriter);
return stringBuilder.ToString();
what can I do?
thanks.
Jerome.