Timer control causing error

Posted on 16th Feb 2014 by admin

I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as I added the timer control and ran my app, I started getting the following error: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: Script controls may not be registered before PreRender.

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: Script controls may not be registered before PreRender.]
System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +236
System.Web.UI.Timer.OnPreRender(EventArgs e) +75
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
I've been using AJAX on this page for months. Why is this timer control suddenly causing me to get a control validation error? Chopped down version of the front end code:1 2 3 4 5 6 The error occurs on page load. I don't get any compilation errors. Any thoughts?

Other forums