Technology, startups, health & entrepreneurial tidbits

Tag Archives: MVC2

ModelBinding ASP.NET MVC and Multiple Field Validation

This tip comes to you from my blog, but the hat-tip goes to Andres Nelson whom I work with at my current client who actually showed me how to do this. The Scenario You have a grid with multiple fields. These fields are dependent upon each other. If one field is empty, then the otherContinue Reading

A Poll: Web Api Calls

A couple of days ago I threw out a poll on twitter to see what people thought of a particular question I had in mind. Here it is: What I’m after is pretty simple … how should one handle exceptional cases in Web Api development. Namily JSON and XML. My take on it is prettyContinue Reading

ASPNET MVC: Handling Multiple Buttons on a Form with jQuery

Sometimes your task in MVC involves many buttons in the same form. Such as the screen shot here. What happens in most situations is that you end up having some code that kind of looks like this: … and then the code looks like this We can solve this with a little jQuery. By attachingContinue Reading

MVC: Unit Testing Action Filters

Certain parts of ASP.NET MVC can be a real pain to test. Namely Model Binders, Action Filters and anything that relies on some magic “Context” that seems to derive from HttpContext, ControllerContext, RequestContext, etc. Below, I’ve outlined how I’ve unit tested a Action Filter. You could extrapolate some of this code into a base TestContinue Reading

jQuery Tip: Brute Force Dirty Form Detection

If you disable your “save” button on your MVC views when the page first loads and want them to be auto-enabled when any input on the form changes, you can do that with the following jQuery snippet. This is sort of a hack*, but it works. With this HTML and this javascript: You’ll “enable” theContinue Reading