I was having some problems regarding the creation of a Page dynamically I do :
p = New Page();
Page myPage = new Page();
FormAtt ctrl = (FormAtt)myPage.LoadControl("path/to/my/file.ascx"); // here lies the gridview of evil
myPage.Controls.Add(ctrl);
Problem is i receive
Control ... must be placed inside a form tag with runat=server
Ok, so I’ve found out that I Need to override the VerifyRenderingInServerForm method to be able to call a formless page, But how can i override VerifyRenderingInServerForm since i don’t have a ASPX file.
ps: I have a related question and I don’t know what to do, since they are different questions but the solution goes to the same problema , and I gave up on the last solution – see : Form is Null in Dynamically created Pages
You can try to use a custom class which already overrides
VerifyRenderingInServerForm: