RegisterForEventValidation can only be called during Render()

G

Guest

I’ve been getting this error after converting my app from .NET 1.1 to .Net 2.0.
RegisterForEventValidation can only be called during Render()
An error occurs when I call RenderControl(oHtmlTextWriter) method.
Can’t use EnableEventValidation="false".
Any help is appreciated.
Thanks
 
T

Teemu Keiski

Hi,

there's no pure workaround since controls register their arguments for event
validation at render. You would need to either override the check on control
level (basically override rendering) or disable event validation. If your
code tries to render the control before the entire page is on Render stage,
you get this error, and it is as the error msg states.

If you can move the logic to do the call to RenderControl etc in Page's
overridden Render method, that could serve as a workarounnd, but it depends
on your scenario can it be applied.
 
G

Guest

Hi,
Thanks for response.
I’ve read all about it.
It’s not going to work in my case.
What I’ll do ,I will override Page.EnableEventValidation property.
public override bool EnableEventValidation {
get {
if (Request.Params["aa"].Trim().Equals("sss")) {
return false; }
else {
return base.EnableEventValidation; }
}
set { base.EnableEventValidation = value; } }

This way I’ll pragmatically control it at least .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top