After all these years building websites with ASP.Net, I have never been in this situation before. I was trying to simply render a server control on a page which didn't have a Form tag.
Of course this naturally produces an error
...must be placed inside a form tag with runat="server"
An easy solution is to override the Page.VerifyRenderingInServerForm Method.
C#
public override void VerifyRenderingInServerForm(Control control){ return; }
VB
Public Overrides Sub VerifyRenderingInServerForm(control As System.Web.UI.Control) Return End Sub
A Voila!
I am always interested in hearing back from those who read my blog. Please leave a comment if you found this useful, want to suggest any changes to my code, or anything else! Thanks!