Editing and binding nested lists with ASP.NET MVC 2

12

Posted by Joe | Posted in Ajax, ASP.NET, C#, JavaScript, jQuery, MVC | Posted on 06-06-2011

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 the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

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

18

Posted by Joe | Posted in Ajax, ASP.NET, C#, jQuery, MVC | Posted on 30-05-2011

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 the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Using the jQuery UI Datepicker with Fancybox

0

Posted by Joe | Posted in jQuery | Posted on 25-08-2010

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;
}

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

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

3

Posted by Joe | Posted in ASP.NET, jQuery | Posted on 18-03-2010

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 the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Populate a select dropdown list using jQuery and Ajax

28

Posted by Joe | Posted in Ajax, JavaScript, jQuery | Posted on 23-02-2010

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 the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Convert all static text email addresses to mailto links using jQuery

2

Posted by Joe | Posted in JavaScript, jQuery | Posted on 18-02-2010

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

Read the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

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

1

Posted by Joe | Posted in Ajax, jQuery, MVC | Posted on 16-02-2010

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 the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Force client-side JavaScript event to fire programatically using jQuery

0

Posted by Joe | Posted in JavaScript, jQuery | Posted on 15-01-2010

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’

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

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

1

Posted by Joe | Posted in Ajax, ASP.NET, JavaScript, jQuery | Posted on 12-01-2010

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 the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Using the jTemplate jquery plugin with ajax and ASP.NET

17

Posted by Joe | Posted in Ajax, ASP.NET, JavaScript, jQuery | Posted on 05-01-2010

Download source

A guy in work introduced me to jTemplates, a template engine plugin for jQuery. It allows you to easily bind JavaScript objects to a defined template and also has some other nifty features.

I’ve found jTemplates to be particularly good when using ajax to display any information quickly and easily.

First I’ll explain how to create a simple template to display data, and then how to use the foreach and cycle features.

Read the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit