More in this section
Blogs RSS feed

Sitefinity intra-site modules: The Unbearable Lightness of Development

by User Not Found
As I have promised in my last post, I have created a Contacts module (previously developed as pluggable module) as an intra-site module. Though, I've said I'll make a post series out of it, creating an intra-site module in Sitefinity is so simple that I can't see how would I span the topic into a series. A single post will do just fine.

I’ve been asked many times is it necessary to use Nolics.Net when developing with Sitefinity and the answer is, of course, no. But as far as I can remember, I don’t think we’ve provided a sample of it anywhere, so I’ve decided NOT to use Nolics.Net in this module… to make things really simple I was using SqlDataSource. That of course doesn’t mean that you can’t use ObjectDataSource or good ol’ SqlDataReader.

The whole project you can download from here. I suggest you do it now because I’ll be referring to the files throughout the post. To illustrate how easy it is to create a new intra-site module, I’ve took the liberty to provide you with a little diagram.

Intra-site module

As the graphic suggests, there is a minimum of four steps that you need to complete in order to create your module. Anything else that you will be doing depends exclusively on the project / module you are working on. These four steps are:

1. Create a folder for your module
2. Create ControlPanel user control
3. Create CommandPanel user control
4. Create Module class

1. Create a folder for your module

Ok, you don’t really need to create a folder for your module. You could have your controls anywhere you please… but it’ll keep things organized if you do. So, as you can see in the project you’ve downloaded, I’ve created a folder ContactsModule in the root folder and that is where I will keep all the module related files.

2. Create ControlPanel user control

Notice that I’ve just said: “user control”. This is one of the biggest differences between pluggable modules and Intra-Site modules. Here, in Intra-site modules, everything is achieved through user controls. Drag-and-drop baby!

I’ve created “Admin” folder inside of my ContactsModule folder to keep all the user controls I’ll be using on the admin side of my modules. You are not required to do that obviously.

The only thing you need to keep in mind with this user control is that it has to implement IControlPanel interface. After you implement the interface, everything else you do is completely up to you. The ContactsModule you’ve downloaded is well commented so I won’t be going into details here.

3. Create CommandPanel user control

This step is very similar to the step 2, except that this time it is CommandPanel user control we are creating and this time we need to implement ICommandPanel interface.

NOTE: You’ll notice that in intra-site module we are implementing interfaces, while in pluggable module we inherit from the base classes. This is of course because user controls need to inherit UserControl class. The implementation is a bit different than in pluggable module, so pay attention to that if you have experience with pluggable modules.

Same as with ControlPanel, after you implement the interface everything else you do is up to you.

4. Create module class

Every intra-site module needs to have a module class that will typically inherit from WebModule class. This class you’ll put in App_Code folder. This is the central class of every module. I’ve commented the code in this class, and you can use this class as a template for your own modules. The parts that need to be modified are rather obvious.

And that’s it…

How to install Contacts intra-site module

Note, you’ll need an already working Sitefinity website.
  • Download the project if you haven’t already
  • Unzip it (good thing I’ve mentioned this, ehh? :)
  • Copy the files from App_Code to the App_Code folder of your already existing Sitefinity website
  • In your database (probably App_Data/Sitefinity.mdf) add the two tables for Contacts module. Those are sample_Contacts and sample_Departments. I’ve provided you with my Sitefinity.mdf file so you can see the schema there or script them from there. Are you missing Nolics yet? If it was Nolics you wouldn’t need to create any tables…
  • Copy ContactsModule folder to the root folder of your already existing Sitefinity website
  • Copy the Sitefinity/Admin/Themes/Default/modules.css to the same place on your already existing website. Alternatively you can simply append the last few styles for the contacts module to your modules.css
  • Make sure you have connection string named “Sitefinity” in your web.config and that it points to the database where you have created the two needed tables. If you don’t you’ll have to modify all SqlDataSource controls in user controls.

Well, I think that’s all. There is really nothing else to explain because everything else is just a familiar ASP.NET stuff. Let me know if you encounter problems or if you have questions.

Sometime next week I’ll publish this module in VB.NET as well… and then the video!

[UPDATE: Apparently I have messed up something with the database file - see comments below - so I am posting the zip of database again. You can download it from here. ]


Leave a comment
  1. Steve H Jan 15, 2008
    Hi, Any news on the VB version of the module and even better the video? Many thanks
  2. Ivan Jan 15, 2008
    Hi Steve, I am sorry, but it completely slipped my mind. I must start keeping a list of promises I made on this blog. I'll make sure to post the VB version soon and then the video as soon as I get some time. Once again, I am sorry for your inconvenience.
  3. Zubair.NET! Feb 03, 2008
    hi Ivan, I'm stuck at step 3 of installation, can you please provide with Sitefinity.ldf, I'm trying to attach your database but it looks like there is a problem and SSMS is missing this file. Thanks,
  4. Zubair.NET! Feb 11, 2008
    hi Ivan, it's been a while since my last post. Can you please put your database and post it here, I need to build my own module and I can't seem to get the DB working even if I create the columns and relationships. Thanks.
  5. Zubair.NET! Feb 11, 2008
    hi Ivan, it's been a while since my last post. Can you please put your database and post it here, I need to build my own module and I can't seem to get the DB working even if I create the columns and relationships. Thanks.
  6. Ivan Feb 12, 2008
    Hi Zubair.NET, sorry for the huge delay... I've been really busy with the upcoming version. Anyhow, I've posted an update at the end of the post with the link for database download. Thanks, for pointing this out.
  7. Tom Jan 12, 2009
    Hello Ivan,

    I was working on your "Create your own module tutorial", but I think the project is outdated. I get 25 errors in VS, and I'm pretty sure I executed all steps properly. The errors are in the Controlpanel.ascx and Commandpanel.ascx and most of them are related to the Radcontrols.
    Do you have any clue about how to fix these errors?

  8. Jason Beck Jan 26, 2010
    I created a new sample site, and installed the sample module as described above. This is with version 3.7 of SiteFinity. Without making any changes, I get an error:

    Parser Error Message: Could not load file or assembly 'RadMenu.Net2' or one of its dependencies. The system cannot find the file specified.

    Source Error:

    Line 1:  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="CommandPanel.ascx.cs"
    Line 2:      Inherits="ContactsModule_Admin_CommandPanel" %>
    Line 3:  <%@ Register Assembly="RadMenu.Net2" Namespace="Telerik.WebControls" TagPrefix="radM" %>
    Line 4:  <%@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %>
    Line 5:  <h2>

    Source File: /Contacts Intra-site Module Sample/ContactsModule/Admin/CommandPanel.ascx    Line: 3

  9. coolguy97 Feb 25, 2010
    I am also getting the same Error
    Using VS 2008 SP1
    SiteFinity 3.7

    Leave a comment