Portal Engine
Version 2.x > Portal Engine > Custom web part errors in CMS Desk Design Tab View modes: 
User avatar
Member
Member
matt - 12/14/2006 6:03:33 PM
   
Custom web part errors in CMS Desk Design Tab
I have created a simple web part based on the examples in the CMS Developer's Guide.

The page on the site loads fine. The Page, Form and Properties tabs load fine in CMS Desk. The Design tab throws the following error. Anyone seen this?

The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

[HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.]
System.Web.UI.ControlCollection.RemoveAt(Int32 index) +2059975
System.Web.UI.ControlCollection.Clear() +25
CMS.PortalControls.CMSAbstractWebPart.CreateChildControls() +83
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +21
System.Web.UI.Control.FindControl(String id) +9
System.Web.UI.WebControls.DataBoundControlHelper.FindControl(Control control, String controlID) +68
System.Web.UI.WebControls.DataBoundControl.GetDataSource() +1819285
System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +34
System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +16
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

User avatar
Guest
admin - 12/18/2006 10:16:11 AM
   
Re: Custom web part errors in CMS Desk Design Tab
You need to ensure that your web part doesn't render any dynamic content (such as grid) in the design mode and that it doesn't use the <%= myfunction() %> inline code methods.

You can check the current view mode using CMS.CMSHelper.CMSContext.CurrentUser.ViewMode property.

We will try to solve this better in the nearest versions.

Best Regards,

User avatar
Member
Member
matt - 12/18/2006 4:04:42 PM
   
Re: Custom web part errors in CMS Desk Design Tab

I see, where do I find the list of valid ViewModes? Also, not to nit-pick but you might want to mention that in the documentation for the Hello World example.

User avatar
Member
Member
thinton99 - 12/18/2006 8:56:33 PM
   
Re: Custom web part errors in CMS Desk Design Tab
I think the only view mode that is NOT valid is ViewModeEnum.Design. I use this, copied from some of the other stock web parts in Kentico:

if ((this.PagePlaceholder.ViewMode == ViewModeEnum.Design) || (this.HideOnCurrentPage) || (!this.IsVisible))
{
// Do not process
}
else
{
// do something here.
}


Todd

User avatar
Guest
admin - 12/20/2006 10:13:42 AM
   
Re: Custom web part errors in CMS Desk Design Tab
That should be correct, Todd. We will try to solve this better or enhance the documentation in the next versions.

Best Regards,