肖恩D++
Not Equal C && !=C && 不等于西
-
Client Side Validation For DataType Attribute in ASP.NET MVC3
Posted on November 20th, 2012 Add commentsAfter Microsoft announced ADO.NET Entity Framework 4.1, database design becomes to very easy via Code First approach. And the DataType Attribute from “System.ComponentModel.DataAnnotations” namespace has been used very popular during Code First. Here are some examples:
12345678public class User{[DataType(DataType.EmailAddress)]public string UserEmail { get; set; }[DataType(DataType.Date)]public DateTime CreateDate { get; set; }}But be noticed, this validation of attribute only fires when you check “ModelState.IsValid” property in Controller or calling “SaveChanges()” in Entity Context, not in the client side. fortunately, JQuery has all the client side validation for those data types. So, the lazy way is just connect them together.
Read the rest of this entry »
642 views
Recent Comments