开发者

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);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜