Monthly Archives: February 2010

Monthly Archives: February 2010

Populate a select dropdown list using jQuery and Ajax

Posted on by Joe in Ajax, JavaScript, jQuery | 35 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. 

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.

ASP.NET MVC – Using Controller.UpdateModel when using a ViewModel

Posted on by Joe in MVC | 30 Comments

When updating a model in MVC it is common to use the Controller.UpdateModel method.  I recently ran into an issue where I was using a custom ViewModel which meant that UpdateModel could not map the updated data back to my model object. The solution to this was a simple one, but not as obvious as it should be due to intellisense not picking up the method’s overloads when the generic type is inferred. 

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

Posted on by Joe in Ajax, jQuery, MVC | 4 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.

Creating and using snippets in Visual Studio 2008

Posted on by Joe in Visual Studio 2008 | Leave a comment

Visual Studio contains a number of predefined snippets. Snippets are usually available for common code that is used frequently allowing the developer to insert this code quickly without having to retype it every time. I often use the try and if snippets, but you can also create your own custom snippets. Recently I found myself to be endlessly creating a try/catch block where in the catch I was logging an exception using a custom logger class, so I decided to create …