I want to create and render a dunamic page. Something like following:
System.Web.UI.Page mypage = new System.Web.UI.Page();
mypage .Controls.Add(new System.Web.UI.HtmlControls.HtmlInputText());
myTextWriter = new StringWriter();
myWriter = new HtmlTextWriter(myTextWriter);
mypage.RenderControl(myWriter);
HttpResponse.write(myWriter.ToString());
But at RenderControl line, I get following Error:
RegisterForEventValidation can only be called during Render()
Is there a way to resolve it? At many forums I found set the EnableEventValidation=false in page directive. But this is a dynamic page and has no directive. Further this property is not available when I browse mypage properties.
and gets the error :Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
enableDeepak
Participant
1069 Points
247 Posts
dynamic page - RegisterForEventValidation can only be called during Render()
Mar 15, 2011 10:23 AM|LINK
Hi,
I want to create and render a dunamic page. Something like following:
System.Web.UI.Page mypage = new System.Web.UI.Page(); mypage .Controls.Add(new System.Web.UI.HtmlControls.HtmlInputText()); myTextWriter = new StringWriter(); myWriter = new HtmlTextWriter(myTextWriter); mypage.RenderControl(myWriter); HttpResponse.write(myWriter.ToString());But at RenderControl line, I get following Error:
RegisterForEventValidation can only be called during Render()
Is there a way to resolve it? At many forums I found set the EnableEventValidation=false in page directive. But this is a dynamic page and has no directive. Further this property is not available when I browse mypage properties.
SocialAuth.NET
tiagosalgado
Contributor
2410 Points
544 Posts
Re: dynamic page - RegisterForEventValidation can only be called during Render()
Mar 15, 2011 10:28 AM|LINK
Try to add this code:
http://geekswithblogs.com/TiagoSalgado
@TiagoSalgado
rory somy
Member
12 Points
7 Posts
Re: dynamic page - RegisterForEventValidation can only be called during Render()
Apr 02, 2012 02:24 PM|LINK
This blocks sending mails :(
and gets the error :Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.