Thursday, February 14, 2013

MVC - Designing the "Model" part of MVC

Yesterday I found myself struggling with the idea of how to implement the Model part of an MVC application in an organized and maintainable way. While googling my way I came across with this two articles that I've found very interesting, and have helped me to clear my thoughts a bit:

http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx
http://lostechies.com/jimmybogard/2009/06/30/how-we-do-mvc-view-models/

Tuesday, February 12, 2013

Best practices for ASP.NET MVC

A must read if you are developing with MVC, from the ASP.NET and Web Tools Developer Content Team blog.

Best Practices for ASP.NET MVC:
http://blogs.msdn.com/b/aspnetue/archive/2010/09/17/second_2d00_post.aspx

Monday, December 17, 2012

Converting Enum to List in C#

This is an easy but recurrent question that I end searching on Google from time to time. So to adhere to this blog's motto and not searching it again here's the solution:

Enum.GetValues(typeof(SomeEnum)).Cast();

(The original solution thread at stackoverflow)

Tuesday, December 4, 2012

NCalc: a mathematical expressions evaluator in .NET


For a project that I've been developing lately I needed to evaluate some mathematical expressions that I'll store as text strings. So my first thought was like "I'm not the first man on earth with such necessity, ergo, it must have been accomplished by someone else before me". That is a thought that I have in a lot of situations, but fortunately this time it turned out to be truth.

As the CodePlex project's page states: "NCalc is a mathematical expressions evaluator in .NET. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions".

IMHO is an excellent tool, but to be fair, I'm not doing nothing overly complicated in my project.

Thursday, November 29, 2012

HOWTO trigger MVC 3 validation from jQuery


Have you ever wonder how to trigger de MVC 3 form validations from jQuery? ... well, I've done it, and belive me, I spend more than an hour finding out how to. So, the answer is pretty simple: to trigger the validators do something like
$('#MyForm').validate().form();
And for checking if the all the validations get passed look for something like
var isMyFormValid = $('#MyForm').validate().valid();
That's all.

(The answer was found thanks to the ASP.NET forums)

Monday, November 26, 2012

Test your javascript code online


Some time ago thanks to an answer at StackOverflow I discovered an amazing web service called jsfiddle. Basically it allows you to test your JavaScript code online with the option to make use of some of the most popular frameworks out there (like jQuery, Mootools, YUI, Dojo, etc..), and if you need so, you can share your "fiddles" too.

An excellent tool that always come handy.