3

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.

rick schott
  • 21,012
  • 5
  • 52
  • 81
Echilon
  • 10,064
  • 33
  • 131
  • 217
  • 1
    possible duplicate of ["The Controls collection cannot be modified because the control contains code blocks"](http://stackoverflow.com/questions/778952/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blo) – Mrchief Aug 25 '11 at 17:46

1 Answers1

0

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

rick schott
  • 21,012
  • 5
  • 52
  • 81
  • Thanks. I did check for <%=, and I'm not using Response.Write(). – Echilon Aug 26 '11 at 07:28
  • This wasn't the cause of my problem. I've been converting .NET 3.5 web apps to 4.0 recently, and I'd left the 3.5 version of the Ajax Toolkit on this particular site. – Echilon Sep 08 '11 at 13:03