开发者

Validation of input into partial view

On an ASP.NET MVC2 Application, I have make a view who contains a partial view. This partial view show data of the model. On the model, i've made several data annotations ([Required]

Bu开发者_如何学Ct, from the controller, ModelState.IsValid is always == true.

Is there something special to do when we want to validate data from a partial view ? I don't know if it's important, i use nhibernate as orm.

Thank's by advance


Okay finally i have fix it with the following code

try
{
  UpdateModel(evaluation, "evaluation");
  //"Update to db" code
}
catch
{
  Evaluation.ViewModels.EvaluationEditViewModel viewModel = new    
  Evaluation.ViewModels.EvaluationEditViewModel();
  viewModel.evaluation = evaluation;
  return View(viewModel);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜