; Alex Davis - Tech Blog

Tech Blog, tutorials and coding examples.

Check out the new flyout jquery plugin!

How to write a basic jQuery plugin

A jQuery plugin is a way of extending the jQuery framework with your own custom methods. It works by extending jQuery’s prototype object which allows your methods to be inheritable and accessible via the jQuery object.

This allows you to harness the power of jQuery by making your method available from the jQuery object itself. Let’s look at a quick example of creating one method by adding it to $.fn. This is shorthand for the jQuery prototype. The example in Listing 1-1 shows a method named colorCode that extend the jQuery prototype object.

MVC Routing Basics

Routing is a fundamental aspect of any ASP .NET MVC project. ASP .NET MVC projects are already configured for basic routing needs. Routing is what drives the application and defines the structure of the urls. The routes that you define map directly to controllers and actions that carry out the behavior of your website. Any actions that the user initiates on the UI will be routed to a specific action on a controller.  

So what defines a route? Basically its just an entry in the RouteTable’s RouteCollection that is defined in the System.Web.R...

Web API Action Filters

One of the challenges working with web services is assuming that the consuming applications are going to do the validation that they should. One way to insure validation takes place when using the ASP .NET Web Api is to write a custom Action Filter. Action filters allow you to validate the input before the controller action executes and are also a convenient way to reuse validation code amoung multiple controller actions.

Here is an example. I have a number of action methods to write for an ASP .NET Web API web service and I want to make sure that a m...

ASP NET Bundling

ASP NET Bundling is a great way to optimze the process of loading javascript and css files into your web application’s browser. It works by reducing the number of requests a browser needs to make in order to get all the javascript and css files required by the application. Instead of the browser making one request per file, it now only has to issue one request per bundle. Fewer requests by the browser means a faster loading page.

When you create a project in visual studio, it automatically enables bundling by adding the System.Web.Optimization N...

Adapter Design Pattern

It’s not uncommon to come across a situation where you need pass data between two parts of a system that have different interfaces. One interface maybe different for functional reasons or it may just be different because it’s provided by a 3rd party and can’t be changed. In this type of situation, the Adapter design pattern enables code with different interfaces to work together.

Examples of where this type of situation can occur are class interfaces between libraries or even different interfaces exposed by web services. Whateve...

Facade Design Pattern

The Facade design pattern hides the details of subsystems it works with so that client applications only have to focus on the details that matter to them. A subsystem is a component of a larger system. Grouping only required functionality to specific subsystems allows the Facade to manage the operations in a more meaningful way. The Facade design pattern also allows you to make changes to different subsystems without having to make changes to the client application.

The system we are going to use in this example is a reservation system that allows peo...