ASP.NET MVC2 Model Validation Fails with Non-US Date Format?

Here's how I solved the issue in my case. I manually validated the date in the controller and reset the ModelState for that property: HttpPost ValidateAntiForgeryToken public ActionResult Save(TestViewModel model) { var tempDate = new DateTime(); var culture = CultureInfo. CurrentUICulture; if(DateTime.

TryParse(Request. Form"TheDate", culture, DateTimeStyles. None, out tempDate)) { model.

DateOfBirth = tempDate; ModelState. Remove("TheDate"); } if(ModelState. IsValid) { // View("Complete", model); } // Validation failed, redisplay the form.

Return this. View("Enter", model); }.

The validation occurs within the DataAnnotations class. You can subclass DataAnnotations classes for your own purposes. I would create a new MultiCultureDateType DataAnnotations class that will validate dates across multiple cultures.

More information: haacked.com/archive/2009/11/19/aspnetmvc....

Here's how I solved the issue in my case. I manually validated the date in the controller and reset the ModelState for that property.

The validation occurs within the DataAnnotations class. You can subclass DataAnnotations classes for your own purposes.

ValidationResult Returned From IValidatableObject. How can I make part of a Joomla template editable via the CMS interface?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions