+1-888-365-2779
Try Now
More in this section
Categories
Bloggers
Blogs RSS feed

Reference: Most important base classes - ControlPanel class

by Ivan Osmak

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

ControlPanel class is based on the ViewModeControl, just as any other View. ControlPanel is a special type of View - namely the root View of every module. In this article we are going to explore how to create a ControlPanel for your own modules and explain the most important members.

 

*** BEGIN NOTE ***

 

If you are building a module which supports multiple providers, you should use ProviderControlPanel class instead of ControlPanel class.

 

*** END NOTE ***

 


Usage


In the base module class (class which inherits from the WebModule base class or SecuredModule class), developer defines which class is a ControlPanel for this module and thus begins the View hierarchy of the module. ControlPanel is defined in the module class by overriding the CreateControlPanel method of the module class. Here is an example of how this looks for the built-in Lists module:
public override Control CreateControlPanel(TemplateControl parent) 
            return new ListsControlPanel(); 
 
The ControlPanel class, in example above ListsControlPanel, is declared as follows:
public class ListsControlPanel : ControlPanel<ListsControlPanel> 

 

*** BEGIN NOTE ***

 

Notice how ListControlPanel is a host to itself. Namely, the root View of the module hierarchy always has the host set to itself.

 

*** END NOTE ***

 

As we have already stated, ControlPanel class inherits from the ViewModeControl and thus the reference of the ViewModeControl is applicable to the ControlPanel class as well.

 

Constructors


ControlPanel class provides two constructors:
  • public ControlPanel()
  • public ControlPanel(bool autoGenerateViewCommands)
The empty constructor will by default turn on the automatic command generation feature. The second constructor offers us the possibility to turn off or on the automatic command generation feature by passing the Boolean value as a parameter.

 


Properties


  • ICommandPanel[] CommandPanels
    Gets an array of command panels containing the defined commands for the current View Mode.
  • BackendBreadcrumb BackendBreadcrumbControl
    Gets the reference to the BackendBreadcrumb control, a required control used by the ControlPanel View.
  • Control ControlPanelView
    Gets the reference to the required control in which the control panel child controls will be loaded.

Methods


  • void CreateStandardCommandPanels(string viewMode, List<CommandItem> commandsInfo, List<ICommandPanel> list)
    This is the method Sitefinity uses to automatically generate the commands. In case modifications need to be made, this method can be overridden.
  • void CreateCommandPanelsFromUserControls(string viewMode, List<string> userControls, List<ICommandPanel> list)
    This method is generally overridden in the actual implementation of the ControlPanel, when command panels based on User Controls should be added. You can find implementation samples here.
  • void CreateCustomCommandPanels(string viewMode, List<ICommandPanel> list)
    This method is generally overridden in the actual implementation of the ControlPanel, when command panels based on the custom controls should be added. You can find implementation samples here.

Leave a comment