Using KnockoutJS with SignalR in ASP.NET MVC

KnockoutJS is a MVVM implementation for JavaScript written by Steve Sanderson, in my opinion the author of the best ASP.NET MVC textbooks available. Simply put it lets you bind a JavaScript object model to your HTML UI using a Read more

A MongoDB Tutorial using C# and ASP.NET MVC

In this post I'm going to create a simple ASP.NET MVC website for a simple blog that uses MongoDB and the offical 10gen C# driver. MongoDB is no NOSQL database that stores information as Binary JSON (BSON) in documents. I Read more

Linq To SQL Tutorial

Check out some of my other Linq to SQL posts: EntityBase Inheritance Modifiers with SQLMetal Linq to SQL with WCF Services Linq to SQL Framework (Repository/Business wrapper) ObjectDataSource binding with server side paging and sorting Load Options Generic Framework using reflection This is a basic tutorial for Read more

Sitecore MVC Tutorial – View Renderings

Posted on by Joe in ASP.NET, C#, MVC, Sitecore | Leave a comment

This is my second Sitecore MVC post following on from Creating your first Sitecore MVC website. In this post I’ll extend what was built in that post to create a dynamic menu using a View Rendering.

Read more

Sitecore MVC Tutorial – Creating your first Sitecore MVC website

Posted on by Joe in ASP.NET, C#, MVC, Sitecore | 1 Comment

In my last post I wrote about setting up your Sitecore solution. I’m now going to extend that to creating your first Sitecore MVC website. This post will build upon the solution created in my other post using TDS and code generation. I’ll keep this post just to the basics of getting the site up an running and then will write further posts to cover the different areas of Sitecore MVC.

Read more

How to set up a Sitecore solution with TDS and Glass Mapper including automatic code generation

Posted on by Joe in ASP.NET, C#, MVC, Sitecore | 1 Comment

In this post I’m going to set up a new Sitecore solution with TDS. I’ll then enable code generation to create glass mapper compatible objects.
Read more

How to write to the Sitecore log

Posted on by Joe in ASP.NET, C#, Sitecore | Leave a comment

Sitecore uses log4net for logging. If you want to write to the log in your own code just use the following.

Sitecore.Diagnostics.Log.Error("Error message", exception);

How to set and read parameters on a static sublayout in Sitecore

Posted on by Joe in ASP.NET, C#, Sitecore | Leave a comment

In Sitecore there are two types of binding, static and dynamic. Static is when you use the Sublayout web control directly in your layout and specific the sublayout you want to use. Dynamic binding is when you use a Placeholder web control and set the sublayout that will appear in that placeholder in Sitecore via the placeholder key. When using dynamic binding you can give your sublayout a Parameters Template and set parameters in Sitecore, but how do you set parameters on a sublayout using static binding?

Read more

Twitter Bootstrap navigation with automatic active class for current page usng ASP.NET MVC

Posted on by Joe in ASP.NET, C#, MVC | 1 Comment

I’ve been playing around some more with Twitter Bootstrap and MVC and wanted to create a top level menu where the active class was added automatically to the item corresponding to the current page. Initially I had an action link inside the list item tag, but as the active class needs to be added to the list item so I decided to create an extension method to generate the entire item for me.

Read more

Optimistic Concurrency with MongoDB C# driver and ASP.NET MVC – Prevent multiple users updating the same record

Posted on by Joe in ASP.NET, C#, MongoDB, MVC | Leave a comment

Over on my MongoDB C# Tutorial Richard asked how you would prevent multiple users from updating the same document. In this post I’m going to update the project in the tutorial to support this.

In my blog example this issue could occur when user 1 clicks to edit a post. While editing, user 2 also edits the same post. User 2 finishes their edit before user 1 and saves the post. User 1 continues editing and saves their changes. User 2′s changes are completely overwritten and neither user has any idea that it happened.

In this implementation, based on the above scenario I’m going to display an error to user 2 to tell them somebody else has updated to the post. They won’t be able to save their changes and it would be up to them to reload the post and make their changes again. Of course you could do something much more exciting, like show the two versions side by side and allow the user to merge the changes.

Read more

Using KnockoutJS with SignalR in ASP.NET MVC

Posted on by Joe in ASP.NET, C#, MVC | Leave a comment

KnockoutJS is a MVVM implementation for JavaScript written by Steve Sanderson, in my opinion the author of the best ASP.NET MVC textbooks available. Simply put it lets you bind a JavaScript object model to your HTML UI using a simple binding format, and when the underlying model is updated the UI is automatically updated to reflect the change.

SignalR is a library from Microsoft utilising HTML5′s WebSockets allowing server side code to call JavaScript functions on the client to create real-time functionality.

To me these two libraries seem like a match made in heaven. SignalR calling a JavaScript function to alter data, and Knockout automatically updating the UI, awesome!

In this post I’ll show how you can use KnockoutJS and SignalR together to create real-time web application with little effort. I’m going to create a very basic example of a web page showing a list of exchange rates hooked up using KnockoutJS. I’ll then create a server side page to update the data and use SignalR to call a JavaScript function to update the JavaScript model.

Read more

A new look!

Posted on by Joe in Personal | Leave a comment

Well I’ve had my blog for nearly 4 years and theme I was running was a bit behind the times. I spent some time today updating to a new responsive theme which I think looks much better!

Twitter Bootstrap validation styles with ASP.NET MVC

Posted on by Joe in ASP.NET, C#, jQuery, MVC | 7 Comments

Well it’s been a while since I’ve been blogging, two kids under 2 will do that to you. I’m going to try and get back into writing some regular posts.

Recently I’ve been playing around with Twitter Bootstrap, so the first thing I wanted to do was add it to an ASP.NET MVC 4 project. Getting the project set up was all pretty easy, and I quickly created a form using the horizontal form styles.

Read more