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.
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.
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 a custom snippet to do this for me. In this post I’ll explain how to create a basic snippet, how to configure Visual Studio to use the snippet, and how to use it in code.
I decided to start a twitter account so if you feel like it you can follow me…
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:
The above will trigger the change event of the control with ID ‘myControl’
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.
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.