Usman ur Rehman Ahmed's blog

Switch DNN default Control Panel

Everyone whom has ever logged in a DNN powered site must have observed the default control panel at the top for administrator and host users. Smart users know how to switch the default control panel from Host Settings. However as a module developer have you ever required to write down a new Control Panel of your own? This post will provide basics of how control panel functions within DNN.

Default control panel is nothing extraordinary but a user control itself (.ascx). The record for all controls (intrinsically available within DNN) or as a result of module installation is stored within table, 'ModuleControls'. DNN distinguishes normal user controls from 'ControlPanel' user controls by means of 'ControlType' field which takes an integer value (A value of -3 refers to 'ControlPanel'). DNN default installation results in two 'ControlPanels' that are stored at path,

    <websiteRoot>\admin\ControlPanel  [as iconbar.ascx and RibbonBar.ascx]

Another important field of this table is 'ControlKey'. While normal controls can be given any value for key, 'ControlPanels' are unique in nature that their keys should be named as, CONTROLPANEL:<YourControlPanelNameHere>. When the drop down of control panels is loaded from Host settings, it is the name given after 'CONTROLPANEL:' for the ControlKey that appeasr in the drop down.

Lastly if you would require switching the default control panel programmatically to a different one, the only thing you will have to do is update the table HostSettings and set SettingValue attribute to point to the control source while ensuring that SettingName is 'ControlPanel'. A query would be more meaningful to explain this concept,

    -- assuming MyControlPanel.ascx user control is stored at path Admin/ControlPanel/

    UPDATE {databaseOwner}{objectQualifier}HostSettings SET [SettingValue] = 'Admin/ControlPanel/MyControlPanel.ascx' WHERE [SettingName] = 'ControlPanel'

This would be equivelent to following,

Control_panel

   

 

11
To Posterous, Love Metalab