Using Kendo UI 2013.2 with S#arp Architecture 2.1.2

By | February 13, 2014

More than half a year ago I posted a similar guide but since then S#arp and Kendo upgraded so those articles will not be helpful for this new versions as there are some changes in both Frameworks.  So here I am again creating this guide for this newer versions.

Like what I had said before we have been using S#arp Architecture for quite sometime now and it proved to be a good platform for some of the enterprise applications we developed in-house for our company, but lately I suddenly lost hope as there were no updates for S#arp but after checking several weeks ago there was an update after 2 years of no releases.  Yay!

For a list of changes a look here

You can also directly download them here

So lets start but before we do that let me tell you this article is taking into consideration that you have created your database with proper naming conventions that works with Fluent NHibernate.   This means the following

  • Table in Plural Form (ie. Employees, Positions, Departments)
  • Table Primary Key is the Singular Form of the Table Name ending in Id (ie. EmployeeId, PositionId, DepartmentId)
  • Use Camel Case in any objects of your Database (ie. ThisIsASampleDatabaseColumn)
  • Define your Foreign Key relationships, maintain the same Naming to the Related Table Column.

Also you should have Kendo UI for ASP.NET MVC 2013.2 or greater installed in your development machine if not, you can get them here (
Now lets start!

  1. Download and Install Templify, you can get the latest version here (

  2. Download and install S#arp architecture version 2.1.2, you can get the latest version here (  Once installed, run templify and deploy templify in the folder of your choice.  Choose a template and a namespace, in this sample we call it WebDemo

01 Templify

  1. Now click deploy.

02 Templify

  1. Go to your folder and it should have a similar structure like this.

03 Extracted

  1. Go into the Solutions folder and your solution will be there.

04 Extracted

  1. Click the solution file, it should open Visual Studio and your solution will look like this.

05 VS Project Structure

  1. Once it opens go to your Presentation Layer, choose the Web Project and set it as StartUp Project.

06 Set as startup project

  1. Set up your database by going to NHibernate.config and choose your database server.  If your Application name is the same as the database name (which I suggest you do) then no need to change the database name.

07 Setup NHibernate Connection String

  1. Run your project for the first time to check if everything is OK

08 Run S#arp

  1. Now lets convert your Website to use Kendo UI.  Right click your web project, choose Kendo UI for ASP.NET MVC then click convert.
    09 Convert to Kendo UI

  2. Choose the latest version and tick only Copy Editor Templates then click next.

10 Convert

  1. Choose a theme you like

11 Choose a theme

13. Add and Install Microsoft.AspNet.Web.Optimization, this is used for bundling and optimizing css and js files.

12 Install Optimization

  1. Add also the new Microsoft jQuery Unobtrusive Ajax, we will need this

14 Unobtrusive AJAX

  1. Now add the following

Take note the references in your Shared Layout (You can find them at  /Views/Shared/_Layout.cshtml) they should be included in your BundleConfig.cs

13 Take note of JS and CSS References

To make your life easier here is a sample BundleConfig.cs code, add and remove references you might need or not need.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;

namespace WebDemo.Web.Mvc.App_Start
public class BundleConfig
    public static void RegisterBundles(BundleCollection bundles)
        // Clear all items from the default ignore list to allow minified CSS and JavaScript files to be included in debug mode

        // Add back the default ignore list rules sans the ones which affect minified files and debug mode

        //Scripts Section
        bundles.Add(new ScriptBundle("~/bundles/jquery")
        bundles.Add(new ScriptBundle("~/bundles/webdemo")

        //Css Section
        bundles.Add(new StyleBundle("~/content/css").Include(

16. Remove all old js and css references in your Shared Layout.  You can find them at  /Views/Shared/_Layout.cshtml

13 Take note of JS and CSS References

  1. Replace with the bundled lines

16a Add Bundles

18. Register them on Global.asax.


17 Register Bundle

  1. Add reference to System.Web.Optimization in your web.config
<add namespace="System.Web.Optimization" />

18 Add Web Optimization on Web Config

  1. Now check if your bundling works by running it and looking at the code behind

19 Check if bundle worked

  1. Try using some Kendo UI components.  For this sample I used a window. You’re free to copy the codes below to try.
    ViewBag.Title = "Home";
    Layout = "~/Views/Shared/_Layout.cshtml";

    .Title("Test Kendo and S#arp")
<div class="armchair">
    <img src="@Url.Content("")"
                    alt="Lorem Ipsum" />
    Lorem Ipsum

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi dictum, quam aliquam aliquam condimentum, ipsum nisi gravida lorem, non dapibus lacus est a est. Integer non convallis dui. Nullam sollicitudin risus id sem varius, eu sagittis lectus condimentum. Integer consectetur euismod justo, nec eleifend lacus cursus sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus scelerisque dui dolor, ac suscipit enim mollis sit amet. Morbi sit amet diam at dolor dictum ullamcorper. Aliquam erat volutpat. Donec gravida pellentesque dignissim. Donec magna nisi, porta eu posuere vitae, fringilla a urna. Mauris sed mi urna. Vivamus et porta est. Donec commodo et odio quis ultrices. Quisque velit purus, iaculis vel ligula id, sagittis molestie neque.

    Aliquam iaculis eros a posuere varius. Quisque fringilla sapien in leo fringilla, eget varius purus placerat. Donec sed leo iaculis, convallis nunc quis, fringilla tellus. Duis luctus, est nec ullamcorper placerat, risus nisi tristique magna, ut suscipit sem nibh vel erat. Nunc aliquam, sem eget consectetur pharetra, mauris libero sollicitudin odio, nec semper nisl neque sed nunc. Integer nec magna mi. Proin eget lacus ut felis gravida interdum. Maecenas ut rhoncus ligula. Sed urna lorem, eleifend in tincidunt vitae, dictum venenatis tortor. Quisque vehicula, enim vel scelerisque lobortis, neque enim volutpat sem, sed consectetur leo quam eu arcu.

    In nec velit non libero vehicula porta. Cras eros sem, viverra vitae tellus vel, tincidunt posuere turpis. Nam vel sodales turpis, vitae commodo magna. Curabitur mattis nunc lacus, quis aliquet ante posuere eget. Vivamus gravida tellus vitae metus tristique, vel malesuada tortor imperdiet. Curabitur nibh velit, porta ut porta quis, bibendum sed orci. Phasellus eu facilisis sem, ac tempor tellus. Aliquam et eros id enim tristique hendrerit. Nullam sed adipiscing ligula, at blandit elit. Sed at metus quis tellus hendrerit pharetra a ut urna. Nam in pretium ligula. Aliquam at ipsum at nunc imperdiet rutrum non in metus. Vivamus lobortis adipiscing lorem eget gravida. Donec sollicitudin velit diam, a sollicitudin dolor convallis at. Suspendisse fringilla ac magna eget feugiat.

            <a href="" title="Lorem Ipsum"></a>
    .Actions(actions => actions.Pin().Minimize().Maximize().Close())
    .Events(ev => ev.Close("onClose"))


<span id="undo" style="displaynone" class="k-button">Click here to open the window.</span>

    function onClose() {

    $(document).ready(function () {
        $("#undo").bind("click"function () {

<style scoped>
    #example {

    #undo {

    .armchair {
        margin30px 30px 120px 30px;

        .armchair img {

Try to run your project then it should look something like this.

20 Test

At this stage your website is ready but if want to make your life easier, I created an open source code generator for S#arp so it generates the domain, presentation (view model, controllers, queries and view) as well as the task layer.  You can download them here or here

You have to change one thing though so your presentation layer can communicate with your Tasks Layer.

First add a reference to SharpArch.Nhibernate on your Task layer

21 Tasks

then go to your presentation layer, under CastleWindsor folder go to TaskInstaller.cs and replace

public void Install(IWindsorContainer container, IConfigurationStore store)
            .Pick().Unless(t => t.Namespace.EndsWith("Handlers"))
            .Configure(c => c.LifestylePerWebRequest())


with this one so we can do Inversion of Control on all of the classes with the WebDemo.Tasks namespace

public class TasksInstaller : IWindsorInstaller
    public void Install(IWindsorContainer container, IConfigurationStore store)
                .Configure(c => c.LifestylePerWebRequest())

You’re all good to go!


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.