Novidades no MVC 5.1
A MS lançou em 20/jan/2014 umas novidades interessantes sobre o MVC 5.1. Confira em http://weblogs.asp.net/jgalloway/archive/2014/01/21/looking-at-asp-net-mvc-5-1-and-web-api-2-1-part-1-overview-and-enums.aspx a lista de algumas features.
Uma que gostei muito é o uso de 2 atributos do DataAnnotations (MinLengthAttribute e MaxLengthAttributelos no AJAX com o this. http://www.asp.net/mvc/overview/releases/mvc51-release-notes#Unobtrusive
E o uso de Enum na classe de forma que a View enxergue, fantástico: http://www.asp.net/mvc/overview/releases/mvc51-release-notes#Enum e http://weblogs.asp.net/jgalloway/archive/2014/01/21/looking-at-asp-net-mvc-5-1-and-web-api-2-1-part-1-overview-and-enums.aspx
public class Person
{
[ScaffoldColumn(
false
)]
public int Id { get; set; }
[UIHint(
"Enum-radio"
)]
public Salutation Salutation { get; set; }
[Display(Name =
"First Name"
)]
[MinLength(3, ErrorMessage =
"Your {0} must be at least {1} characters long"
)]
[MaxLength(100, ErrorMessage =
"Your {0} must be no more than {1} characters"
)]
public string FirstName { get; set; }
[Display(Name =
"Last Name"
)]
[MinLength(3, ErrorMessage =
"Your {0} must be at least {1} characters long"
)]
[MaxLength(100, ErrorMessage =
"Your {0} must be no more than {1} characters"
)]
public string LastName { get; set; }
public int Age { get; set; }
}
//I guess technically these are called honorifics
public enum Salutation : byte
{
[Display(Name =
"Mr."
)] Mr,
[Display(Name =
"Mrs."
)] Mrs,
[Display(Name =
"Ms."
)] Ms,
[Display(Name =
"Dr."
)] Doctor,
[Display(Name =
"Prof."
)] Professor,
Sir,
Lady,
Lord
}
bons estudos e sucesso nos projetos.
Renatão