Category: Development

  • jQuery HTML Templates

    There is an updated version of this article: jQuery HTML Templates: 3 Solutions to get you started

    When you have a lot of AJAX calls on your website, especially ones that return a list of data, it can be quite expensive processing time on the server to retrieve the results, format them with HTML, and return them to the browser to display – not only that, your bandwidth costs can be quite high as well. With jQuery templates, you can alter your AJAX calls to return JSON leveraging Javascript event handlers, and then populate the content client-side providing faster response times and less server processing as well from an external file or JSON object.

    (more…)

  • Knockout – Uncaught ReferenceError: Unable to process binding

    If you’ve used Knockout.js in your project to process binding, at some point or another you’ve probably encountered the following error message Uncaught ReferenceError: Unable to process binding. The most likely cause is a typo somewhere or forgetting to change the context. E.g. you are within a foreach binding and forget to use $parent especially inside your jquery HTML template.

    (more…)

  • Catching multiple exceptions with C#

    Exception handling with Try/catch blocks are a part of my everyday life. But I’m not a fan of catching all exceptions. I prefer handling only the ones I expect to be thrown in specific situations where I want to explicitly do catching multiple exceptions. Of course I can accomplish this with multiple catch blocks, but when they all do common things I would like a simpler way to avoid code duplication. Another great example would be how to use C# Convert any value to a boolean.

    (more…)

  • Updating specific fields using Entity Framework

    Entity framework does a great job of detecting when a field changes on any object that it is tracking. These changes will be automatically saved when SaveChanges is executed. As I discussed in Why the Repository Pattern I like to create an example Generic Class that is type T where T is a Model or a User in my Entity Framework Context. This example will extend upon those context query to retrieve the modified entry.

    (more…)

  • Create GUID / Create UUID in JavaScript

    Javascript create guid

    Generate uuid

    Most server-side languages and databases provide built-in support for UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier). At the time of writing JavaScript does not, so let’s create our own UUID generator with JavaScript array.

    There are a few other examples out there that use random numbers and date parts; however, I found this solution that leverages window.crypto.getRandomValues. There are also of course of few libraries out there, most notably node-uuid (npm install uuid) for your universally unique identifier, but sometimes it’s fun to create things on our own for experimentation with the crypto api to generate UUID.

    (more…)