asp.netajaxupdatepanelscriptmanagertoolkitscriptmanager

AJAX SciptManager causing problems


I'm trying to get a ScriptManager working in .NET 3.5 but getting a scriptmanager exception. I've just removed all of the UpdatePanels from the page and refactored everything into UserControls so the page is no longer written like a VB5 app. The ToolkitScriptManager is on the masterpage, and I've tried with and without a ScriptManagerProxy on the offending page.

I get a stacktrace with the following error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8690071
   AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in d:\hg\act\Server\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:323
   AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in d:\hg\act\Server\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:305
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

I can't see any <%= tags in the code and I'm getting desperate now. How would I go about tracing the source of the error. Any help is appreciated.


Solution

  • In addition to removing and <%= ..%>, make sure you don't Response.Write anything in the code-behind(s).