J
Josh Carver
Hi group,
I'm trying to get the outputted html from some specific controls on a page,
and I'm finding that some controls will render fine, while others will throw
the error that "[control] must be placed inside a form tag with
runat=server." For example, a label control will render fine, but a button
will not. It seems that any control that has a server-side click event will
not accept being rendered in this way. Does anyone know what I can do to
get such controls to render? Here's my code:
aspx snippet:
<form id="f" runat="server">
<div>
<asp:Label ID="control" runat="server" Text="Chage to an asp:Button"
/>
</div>
</form>
..cs snippets:
using System;
using System.Web.UI;
using System.IO;
// ...
using (StringWriter sw = new StringWriter())
{
HtmlTextWriter htw = new HtmlTextWriter(sw);
control.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
Thanks for any help.
Joshua C
I'm trying to get the outputted html from some specific controls on a page,
and I'm finding that some controls will render fine, while others will throw
the error that "[control] must be placed inside a form tag with
runat=server." For example, a label control will render fine, but a button
will not. It seems that any control that has a server-side click event will
not accept being rendered in this way. Does anyone know what I can do to
get such controls to render? Here's my code:
aspx snippet:
<form id="f" runat="server">
<div>
<asp:Label ID="control" runat="server" Text="Chage to an asp:Button"
/>
</div>
</form>
..cs snippets:
using System;
using System.Web.UI;
using System.IO;
// ...
using (StringWriter sw = new StringWriter())
{
HtmlTextWriter htw = new HtmlTextWriter(sw);
control.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
Thanks for any help.
Joshua C