onvalidate in mvc2
How do I implement the OnV开发者_运维百科alidate method in mvc2? I'm reading an article which shows onvalidate method but I can't find in visual studio 2008?
I haven't seen an OnValidate() method in ASP.NET MVC. You may have seen a validation mechanism in LINQ-to-SQL.
In ASP.NET MVC, I'll usually check validation like so:
public ActionResult Update(SomeModel viewModel)
{
if (!ModelState.IsValid)
return View("Edit", viewModel);
// some update code...
PutTempMessage("data updated.");
return View("Edit", viewModel);
}
精彩评论