Enabling and Disabling Sitefinity Inline Editing

Sitefinity includes a helpful inline editing feature, which allows an authorized user to quickly update content on the public website instead of the administration backend. This can be enabled for all, some, or no users, depending on your needs and configuration

Programmatically Adding Controls to a Sitefinity Page

The PageManager in Sitefinity has a method called CreateControl that is overloaded to allow both Compiled (dll) controls as well as simple User Controls (.ascx files) to be initialized and added to a Sitefinity page. Both overloads require a string containing the name of the ContentPlaceholder that will hold the control, which is defined in the .master file backing a Sitefinity template.

CreateControl Method and Sample Code

For compiled web controls, the signature of the CreateControl method looks like this:

CreateControl<T>(System.Web.UI.Control control, string placeHolder)

Here is an example code snippet that creates a NewsView control and adds it to a page.

View code sample on Gist

The method for UserControls, on the other hand, accepts a string with the relative path to the user control (such as “~/widgets/control.ascx”):

CreateControl<T>(string controlPath, string placeHolder)

Here is an example code snippet that creates an instance of a user control and adds it to the page.

View code sample on Gist

In both methods, the generic type <T> should be PageControl.

Adding Controls in Order

Controls added to Sitefinity Pages load at runtime in no particular order, and even if you add them in a specific sequence, they may load on the page in a different order.

Fortunately, you can specify the order the widgets should load by using the SiblingId property of the control, which refers to the ID of the control that should precede it in the placeholder.

The first control should have this value be empty, since it is at the top and has no previous sibling control. After adding the control, save the ID, and assign it to the SiblingID property of the next control you wish to load.

Here is a simple example that demonstrates this, adding the three controls so they load in order on the page. This example demonstrates using a User Control, but the property works for compiled controls as well.

View code sample on Gist

Introducing WunderLook: An Outlook Add-in for Wunderlist

This is my first attempt at writing both an Outlook Add-in as well as developing with Wunderlist. They don’t have an official API that I could find, but I did discover the .NET Wunderlist API by lerainieur on SourceForge which is a major component of this project. Many thanks to the developer for making this available.

Developing an Add-in for Outlook 2010

I had a difficult time just finding relevant and useful information on just how the heck you do this. I searched for hours on MSDN, as well as general searching on the internet for variations of “how to create an outlook add-in” that yielded pretty useless results.

So this blog post is meant to list some of the helpful resources I WAS able to find, as well as some of the things I learned along the way.

Wunderlist: The Ultimate Solution for Managing Tasks

So finally, after many years of searching (this is a problem I’ve been trying to solve long before WP7), I finally discovered Wunderlist. Rarely does one find a solution so complete, so closely matched to their needs that when it happens, you just have to sit back and enjoy it.

Downgrading an SQL Server Database Using Scripts

One of my biggest annoyances about SQL Server is the inability to load a database from a later version into a previous one. Database files and backups don’t have any indicators of their version (unless you are OCD enough to enforce naming conventions) so whenever I get a backup file from a client (or from my archive) it’s a crapshoot which server it belongs to.

Worst of all, restoring it to a LATER version IS supported, so if I have an SQL Server 2005 backup and restore it to my local SQL Server 2008, it works fine. Then when I attempt to deploy it to the server it’s supposed to go, I get the dreaded error:

The database ‘DatabaseName’ cannot be opened because it is version XXX. This server supports version XXX and earlier. A downgrade path is not supported.

Which is even more infuriating, because God forbid it says something helpful like “version SQL Server 2005” or “version SQL Server 2008” instead of the cryptic and useless “661” and “655”. 2005 was seven years ago and we still don’t have a better error message for this?

So, to make sure I don’t change the version of the database, I have to first try SQL Server 2005, to ensure that it doesn’t attempt to update it if it’s the wrong version. Then I have to go up the chain through 2008 and 2008 R2 because of course I’m not going to remember which number goes with which version…

Of course, the worst part is when the database was created on a later version of SQL Server, but needs to be deployed to a prior version. It’s a rare situation these days, especially since these days I insist needing help with their database be very clear about their environment.

But alas, sometimes it happens, and of course when it does, it’s a pain in the ass to fix. In some cases you can just use the Copy Database or Import Export tools of SQL Server, but these often fail if you’re trying to sync between SQL Server and SQL Express.

The most sure-fire way I’ve found to do the downgrade is to script the entire database (along with all its data) and run that script on the desired instance.

Unfortunately (again!), this is also prone to fail, espcially if your scripts end up being extremely large, resulting in the error:

Exception of type ‘System.OutOfMemoryException’ was thrown.


So long story short (too late!), the solution is to use the SQLCMD utility which is a command line interface for executing SQL commands. This utitliy will execute scripts one line at a time, ensuring that they complete without throwing a memory error.

So once your scripts are generated, launch the sqlcmd utility and execute the following command:


This of course expects that you have the username and password to the server and can connect to it from that machine. For other connection scenarios, refer to the SQLCMD Utility Reference.

Once the database is loaded, you can finally back that up and deploy it to the desired server.