Sitefinity CMS

Telerik.Framework Send comments on this topic.
ControlPanelBase Class
See Also  Members   Example 
Telerik.Web Namespace : ControlPanelBase Class


Base class for control panel controls. Implements the IControlPanel interface

 

Namespace: Telerik.Web
Assembly: Telerik.Framework (in Telerik.Framework.dll)

Syntax

Visual Basic (Declaration) 
Public MustInherit Class ControlPanelBase 
   Inherits CompositeControl
   Implements IControlPanel 
Visual Basic (Usage)Copy Code
Dim instance As ControlPanelBase
C# 
public abstract class ControlPanelBase : CompositeControl, IControlPanel  

Example

The example bellow provides example of ControlPanelBase abstract class implementation. For the sake of simplicity most of the methods are clipped. The ControlPanel class provides Mode property so that differently controls could be rendered depending on it, thus imitating separate controls. The controls to render are determined on the CreateChildControls method. The ControlPanel constructor also takes care about the CommandPanel controls initialization. In this case it initializes one new control which is supposed to implement the ICommandPanel interface.
C#Copy Code
public enum DisplayMode
{
   CategoriesList,
   CategoriesEdit,
   TypesList,
   TypesEdit
}

public class ControlPanel : ControlPanelBase
{
   
public ControlPanel()
   {
       
base.commandPnls = new ICommandPanel[] { new ToolBoxPanel(this) };
   }

   
public DisplayMode Mode
   {
       get
       {
           
return this.mode;
       }
       set
       {
           
this.mode = value;
       }
   }

   
protected override void OnInit(EventArgs e)
   {
       
base.OnInit(e);

       
base.Title = Messages.ModuleTitle;
       
if (base.Page != null)
       {
           
base.Page.RegisterRequiresControlState(this);
       }
   }

   
protected override object SaveControlState()
   {
       
//Save information in the control state here.
   }

   
protected override void LoadControlState(object savedState)
   {
       
//Load the information from the control state.
   }

   
protected override void CreateChildControls()
   {
       
this.Controls.Clear();

       
switch (this.mode)
       {
           
case DisplayMode.CategoriesList:
               CreateCategoriesListView();
               
break;
           
case DisplayMode.CategoriesEdit:
               CreateCategoriesEditView();
               
break;
           
case DisplayMode.TypesList:
               CreateTypesListView();
               
break;
           
case DisplayMode.TypesEdit:
               CreateTypesEditView();
               
break;
       }
   }

   
private void CreateCategoriesListView()
   {
       
//Provide implementation for creating the categories list view controls.
   }

   
private void CreateCategoriesEditView()
   {
       
//Provide implementation for creating the categories edit view controls.
   }

   
private void CreateTypesListView()
   {
       
//Provide implementation for creating the types list view controls.
   }

   
private void CreateTypesEditView()
   {
       
//Provide implementation for creating the types edit view controls.
   }

   
public void SetMode(DisplayMode mode)
   {
       
this.mode = mode;
       
this.ChildControlsCreated = false;
   }

   
private DisplayMode mode;
}
    

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also