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

Twitter Bootstrap validation styles with ASP.NET MVC

Posted on by Joe in ASP.NET, C#, jQuery, MVC | 8 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

Editing and binding nested lists with ASP.NET MVC 2

Posted on by Joe in Ajax, ASP.NET, C#, JavaScript, jQuery, MVC | 22 Comments

Dynamically editing lists of data and binding back to the model with MVC is a little complicated as the id’s of the form elements need to all tie up for binding to succeed. Recently I had a model, which contained a list of an object, which in turn contained another nested list. Getting this to easily bind back to the model when adding to the lists dynamically was a bit of a headache so I’ll explain how I did it.

This article is inspired by this article by Steve Sanderson, but I also explain how to adapt it to bind nested lists.

Read more

ASP.NET MVC simple server-side ajax paging using jQuery

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

It’s always important to page your data on the server side so that you are only hitting the database to get the page you currently need, rather than getting all the results and paging on the client. In this post I’ll explain how to perform simple ajax paging on the server side using ASP.NET MVC 3.

Read more

Using the jQuery UI Datepicker with Fancybox

Posted on by Joe in jQuery | 3 Comments

I just wasted what seems to be far too much of my life (about 30 minutes), trying to figure out why the jQuery UI Datapicker wouldn’t work when it was applied to a text box within a Fancybox.

It turns out it was working, but it was being placed behind the Fancybox which had it’s z-index set to 1101.

Adding the following CSS worked a treat

#ui-datepicker-div
{
    z-index: 1102 !important;
}

How to select checkboxes in an ASP.NET CheckBoxList using jQuery

Posted on by Joe in ASP.NET, jQuery | 5 Comments

I came across a situation where I needed to make sure at least one checkbox in an ASP.NET CheckBoxList is checked before submitting the page.  Looking at the source each checkbox element created shares the same client ID with a different number at the end, so I needed a way to select all checkboxes where the ID started the same.

Read more

Populate a select dropdown list using jQuery and Ajax

Posted on by Joe in Ajax, JavaScript, jQuery | 41 Comments

In this post I’ll explain how to populate a select dropdownlist using jQuery and Ajax.  I am using an ASP.NET web application and page methods to perform the Ajax calls.  Using page methods means that you do not need a seperate web service, which is good if the functionality is specifically for the page.  The page methods must be declared public static and use the WebMethod attribute. 

Read more

Convert all static text email addresses to mailto links using jQuery

Posted on by Joe in JavaScript, jQuery | 6 Comments

In this post I’ll show how to use  jQuery to automatically convert all email addesses from static text into a mailto link.

Read more

Creating a Delete link with MVC using POST to avoid security issues

Posted on by Joe in Ajax, jQuery, MVC | 6 Comments

It is fairly common to have a list of records with a hyperlink to delete a record.  The problem here is that with MVC the hyperlink will use a GET request to delete a record.  This is a fairly big security issue as anybody can browse to the URL and delete a record from your system.  In this post I’ll explain how you can use the Ajax helpers to create a hyperlink that will call your delete method without using GET.

Read more

Force client-side JavaScript event to fire programatically using jQuery

Posted on by Joe in JavaScript, jQuery | Leave a comment

Earlier today I needed to force a clide side event to fire programatically using jQuery.

I found you can do this easily with the jQuery trigger method:

$("#myControl").trigger("change");

The above will trigger the change event of the control with ID ‘myControl’

Edit in place / inline editing with jQuery, jTemplates and ASP.NET

Posted on by Joe in Ajax, ASP.NET, JavaScript, jQuery | 1 Comment

Download source

In this post I talked about how to use the jTemplates plugin for jQuery. Using my final example in the post I thought it would be cool to try and add some ‘edit in place’ functionality to the table.

For this to work I’ve created a Data Access Layer using Linq to XML. My web service then uses this DAL to save and retrieve my data.

Read more