Transferring modules built prior to Sitefinity 3.6 to the new backend architecture: Breaking Control Panel modes into Views

Transferring modules built prior to Sitefinity 3.6 to the new backend architecture: Breaking Control Panel modes into Views

April 21, 2009 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]


As we have stated in the Overview of this topic, our first task is to break Control Panel modes into Views. Whereas ControlPanel modes used to be only the enumeration on which we used to create (hide or show) different controls, with Views we are actually going to create a separate control (View) for each of these modes.


Let us examine this task on the Sitefinity built-in Lists module. In the old implementation we used to have following enumeration representing various modes of the Lists module ControlPanel:
        /// <summary>Represents the display mode of the <see cref="ControlPanel"/>. </summary> 
        public enum DisplayMode 
            /// <summary>Displays all lists.</summary> 
            /// <summary>Displays a single list and all of its items.</summary> 
            /// <summary>Adds a new list.</summary> 
            /// <summary>Edits an existing list.</summary> 
            /// <summary>Adds a new item.</summary> 
            /// <summary>Edits an existing item.</summary> 
            /// <summary>Manages permissions of the lists module</summary> 
Then, depending on the currently selected mode we would create the user interface in the CreateChildControls method, which used to look like this:
            switch (this.mode) 
                case DisplayMode.AllLists: 
                case DisplayMode.NewList: 
                case DisplayMode.EditList: 
                case DisplayMode.ViewList: 
                case DisplayMode.NewItem: 
                case DisplayMode.EditItem: 
                case DisplayMode.Permissions: 
With further conditioning implemented in the CreateAllLists, CreateListView and CreatePermissionsView methods.


So, the first order of business is to create Views for each of the modes ControlPanel had. By doing that, we’ve ended up with following Views in the new implementation of the Lists module:

  • AllListsView
  • ListEdit
  • ListInsert
  • ListItemEdit
  • ListItemInsert
  • ListItemsAll
  • ListsAll
  • PermissionsView

You can see that the Views are following the modes very closely in their functionality and intention.


Now, that the Views have been created, new Sitefinity backend architecture will take care of all these conditions that we used to have to implement in order to always display correct UI. Once the Views are defined, we need to separate the ControlPanel template into a separate template for each View and finally move the event handlers and methods of ControlPanel to their respective Views.


With the Views separated, we can follow the instructions described in articles “What are Views?” and “Adding Views to ControlPanel” to wire up all the Views together into a module hierarchy.


The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments are disabled in preview mode.
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

More From Progress
ProgressNEXT: Premier Event for Modern Application Development
Read More
Seven Reasons to Check Out Sitefinity 11.1
Read More
Getting Started with Your Omnichannel Content Strategy
Read More