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.
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> |
AllLists, |
/// <summary>Displays a single list and all of its items.</summary> |
ViewList, |
/// <summary>Adds a new list.</summary> |
NewList, |
/// <summary>Edits an existing list.</summary> |
EditList, |
/// <summary>Adds a new item.</summary> |
NewItem, |
/// <summary>Edits an existing item.</summary> |
EditItem, |
/// <summary>Manages permissions of the lists module</summary> |
Permissions |
} |
switch (this.mode) |
{ |
case DisplayMode.AllLists: |
this.CreateAllLists(); |
break; |
case DisplayMode.NewList: |
case DisplayMode.EditList: |
case DisplayMode.ViewList: |
case DisplayMode.NewItem: |
case DisplayMode.EditItem: |
this.CreateListView(); |
break; |
case DisplayMode.Permissions: |
this.CreatePermissionsView(perm.CheckDemand(CrudRights.ChangePermissions)); |
break; |
} |
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:
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.
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.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.