Home
Atom Feed

My First Umbraco Usercontrol - Part 1: Setting up Visual Studio

For a long time, I have been able to develop for Umbraco only by using XSLT.
However, recently I got a task that could not be solved by XSLT alone. I have never done a usercontrol before, so this was sure to be an interesting experience. The task is to find a way to generate a CSV representation of any Umbraco page.

I decided to write a series of blog posts about my progress, to hopefully aid other people in understanding usercontrols.

Part 1a: Setting up Visual Studio 2010

First, we need to create a new Web Application. To ease the process of setting up the usercontrol in Visual Studio 2010, I created a template which you can download here.

First, install the template you just downloaded by double- clicking on it. If the file has a .zip extension, rename it to .vsix.

Then create a new Web Application by clicking "File" -> "New Project" -> "Visual C#" -> "Umbraco UserControl". You can call the usercontrol whatever you like, but make sure there are no spacesDots might also get you in trouble. My project is called "EyeCatchCSVGenerator".

Part 1b: Setting up Visual Studio 2008

First, create a new Web Application (You can find it by clicking "New Project" -> "ASP.NET Web Application"). You can call it whatever you like,but make sure there are no spacesDots might also get you in trouble. My project is called "EyeCatchCSVGenerator".

Then you need to copy some files from Umbraco to your "bin" folder. Not all of the following files are necessary, but I included them just in case.

  • umbraco.dll
  • umbraco.editorControls.dll
  • cms.dll
  • interfaces.dll
  • businesslogic.dll

You also need to add references to these files. You can do this by right- clicking the "References" folder and press "Add Reference". Then you go to the "Browse" pane, and locate the .dll files you just copied.

Finally, your project should look like this:

 

Now, you can choose if you want to create a separate Visual Studio project for every usercontrol or just make one that contains them all.

A.        One Project, One UserControl (My preference)

In this case you create one project per usercontrol you develop. I think it is a much cleaner way of development.

The setup here is simple, just right -click your project and click "Add New Item", then choose "Web User Control". Give your usercontrol a proper name.

B.        One Project, Multiple UserControls

In this case you create a separate folder for every usercontrol inside the project.

Right -click your folder and click "Add New Item", then choose "Web User Control". Give your usercontrol a proper name.