Unfortunately MVC3 doesn’t respect the [Required] attribute’s AllowEmptyStrings property. When using a class both as an MVC model and as an EF Code First entity this is a problem. What if I want to allow empty strings, but not null values in the database? The problem lies in the client side validation performed by MVC3.… Continue reading EF Code First/MVC NotNullAttribute
Tag: ASP.NET MVC3
Indexed SelectList Factory
In the Type Safe SelectList Factory post I showed one way to improve the SelectList constructor. Recently I wrote another one, when I needed a SelectList that has the selected item’s index as the value. I used this together with jQuery to get details about the selected item from a separately supplied json array.
Type Safe SelectList Factory
I think that ASP.NET MVC is a huge step forward from ASP.NET Web Forms. Still, there are some parts of it that are disappointing. One is the SelectList constructor, that doesn’t use generics and has string parameters for field selection. To create a SelectList from an IEnumerable<> we would do something like this. IEnumerable<Person> people… Continue reading Type Safe SelectList Factory
Catch Errors in ASP.NET MVC Views
The compiler is my friend. It helps me check for simple spelling mistakes and alerts me when a change in one part of the code base breaks a reference somewhere else. When developing in ASP.NET Web Forms I have had a hard time with the lack of compilation of aspx pages. As long as the… Continue reading Catch Errors in ASP.NET MVC Views