ASPX templates
Version 7.x > ASPX templates > ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases View modes: 
User avatar
Member
Member
kdeshane-pixelmedia - 12/18/2012 9:49:48 AM
   
ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases
Using version 7.0.12, .NET 4.0

I have a site using aspx, and I am attempting to setup a page template to use ASPX + Portal page. I have added the portal manager and script manager to my master page:
<cms:CMSPortalManager runat="server" ID="manPortal" EnableViewState="False" />
<ajaxToolkit:ToolkitScriptManager runat="server" ID="manScript" EnableViewState="False" ScriptMode="Debug" />

However, I now get an error on any Page tab in the CMSDesk, as well as on the Design tab on any pages that use the new template:
[HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.]
System.Web.UI.ControlCollection.Add(Control child) +12546592
CMS.UIControls.ContentPage.EnsureScriptManager() +361
CMS.ExtendedControls.CMSUpdatePanel.OnInit(EventArgs e) +110
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.AddedControl(Control control, Int32 index) +189
CMS.PortalControls.CMSPortalManager.CreateEditMenu(PageInfo pi, Boolean isPreview, ViewModeEnum viewMode) +610
CMS.PortalControls.CMSPortalManager.CreateChildControls() +725
System.Web.UI.Control.EnsureChildControls() +189
CMS.PortalControls.CMSPortalManager.CMSPortalManager_Init(Object sender, EventArgs e) +511
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098

I've seen this thread, which points to another thread that supposedly solves the error, but neither of the solutions solves my issue. Does anybody have a solution that works?

Thanks.

User avatar
Kentico Customer Success
Kentico Customer Success
Accepted solutionAccepted solution
kentico_martind2 - 12/18/2012 9:59:05 AM
   
RE:ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases
Hello,

Please take a look at our Developers Guide: Creating ASPX master pages
where you can find the following sentence near CMSPortalManager... Always place this control after the ToolkitScriptManager control. + you can find there example codes. The order is important.

Best regards,
Martin Danko

User avatar
Member
Member
kdeshane-pixelmedia - 12/18/2012 10:01:31 AM
   
RE:ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases
Thank you Martin! That solved the problem and everything is working now.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/18/2012 10:08:40 AM
   
RE:ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases
Hi,

I'm glad that it's working now! You're welcome.

Best regards,
Martin Danko

User avatar
Certified Developer v6
Certified Developer v6
kmurphy-wakefly - 2/3/2014 1:51:39 PM
   
RE:ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases
Thanks Martin, this thread bailed me out of an issue with a client.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 2/3/2014 2:52:49 PM
   
RE:ASPX + Portal Page - The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases
Hi,

Excellent! Let me say that you did a great job :)

Regards,
Martin Danko