I have a webmethod which will be called from jquery ajax:
[WebMethod]
public string TestMethod(string param1, string param2)
{
StringBuilder b = new StringBuilder();
HtmlTextWriter h = new HtmlTextWriter(new StringWriter(b));
this.LoadControl("~/Pages/Controls/Listing.ascx").RenderControl(h);
string controlAsString = b.ToString();
return controlAsString;
}
(it's a non-static method and we are able to hit it. That's not an issue)
When the loadControl() method is executed, I get an error saying: RegisterForEventValidation can only be called during Render.
I have already included EnableEventValidation="false" for the current aspx, disabled viewstate also. but still i get the same error. Any ideas on this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…