Create New Controls

Controls are server-controls that can be used throughout any theme in BlogEngine.NET and they are all located in the App_Code folder.

Getting started

The easy way to start with building new controls is to look at some of the simple ones like MonthList. Basically, a control just renders HTML at the location they are placed on a theme. You can take full advantage of the BlogEngine.Core namespace which holds any information about posts, pages, categories etc.

The right namespace

It is important that you place your custom control in the same namespace as the rest of the controls.

namespace Controls
{
    // Your control class
}
By using the Controls namespace any theme can use the new control without registering it anywhere. It automatically becomes usable everywhere by inserting tags prefixed with blog:

<blog:YourControl runat="server" />

Deploying the new control

When your control is finished you just need to upload it to the App_Code folder on the web server. Next, you have to add it to your theme and upload that as well. Now the new control is deployed and ready to use.

Administer the control

If the new control has properties that have to be configured, you can add a custom page to the admin section. The page can be filled with text boxes, drop down lists etc. that is needed to configure the control. For storing the settings, it is recommended that you use text or XML files and place them in the App_Data folder.

When the admin page is done, just place it in the /admin/pages/ folder and it automatically shows in the admin menu and is ready for use.

Last edited Mar 7, 2009 at 10:03 PM by BenAmada, version 1

Comments

jlesinski May 20, 2014 at 5:48 PM 
Is there updated documentation for creating controls? It seems as though they are tied to widgets now and I am wondering if there is a current write-up?