Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
RegisterForEventValidation can only be called during Render()

I added a WebHTMLEditor control and WebSpellChecker control onto a UserControl. I then set the SpellCheckerId property on WebHTMLEditor to the id of WebSpellChecker. I then reference the UserControl from an ApplicationPage. After deploying the SharePoint site the page loads, I enter text into the editor and click the SpellCheck button. A dialog box opens with the text "Spell Checking Document" for about a second and then is replaced by the error below. What should I do to resolve this issue?

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: RegisterForEventValidation can only be called during Render();

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: RegisterForEventValidation can only be called during Render();]
   System.Web.UI.ClientScriptManager.RegisterForEventValidation(String uniqueId, String argument) +10981598
   System.Web.UI.HtmlControls.HtmlInputText.RenderAttributes(HtmlTextWriter writer) +108
   System.Web.UI.HtmlControls.HtmlControl.RenderBeginTag(HtmlTextWriter writer) +57
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +13
   Infragistics.WebUI.WebControls.WebPanelBase.RenderContents(HtmlTextWriter writer) +349
   Infragistics.WebUI.WebControls.WebPanelBase.Render(HtmlTextWriter writer) +54
   Infragistics.WebUI.WebSpellChecker.WebSpellCheckerDialog.Render(HtmlTextWriter writer) +163
   Infragistics.WebUI.WebSpellChecker.WebSpellChecker.RenderDialog(HtmlTextWriter writer, WebSpellCheckerDialog dialog) +959
   Infragistics.WebUI.WebSpellChecker.WebSpellChecker.OnInit(EventArgs e) +526
   System.Web.UI.Control.InitRecursive(Control namingContainer) +143
   System.Web.UI.Control.InitRecursive(Control namingContainer) +391
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +271
   TestWeb.Layouts.TestWeb.MyDisplayPage.Page_Load(Object sender, EventArgs e) +282
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e) +101
   Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e) +49
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

Server Error in '/' Application.

RegisterForEventValidation can only be called during Render();


  • 65

    To get around this problem, you can turn off Event Validation at the page level.  I wouldn't recommend this until you consider the security ramifications of doing so.  It may or may not make sense, given the context of your page.  In our case, it did make sense because the text was the only input we were considering (for instance, our page contains no dropdown lists that contain values constrained by authorization rules, etc.).

    To turn off Event Validation, you can add the EnableEventValidation attribute to the Page directive.  See below.

    <%@ Page EnableEventValidation="False" ...