How to manually check if model is valid or not

Total Post:9

Points:63
 554  View(s)
Ratings:
Rate this:

I want to check the data is valid or not

 public ActionResult ValidCheck(student model)

    {

        Models.ViewModel.User model = new Models.ViewModel.User();
        model.Age = 12;
        model.Name = "Andy He";
        model.Email = "123";
        //TryValidateModel(model);
     }

could you help me?

  1. Post:5

    Points:35
    Re: How to manually check if model is valid or not

     public ActionResult ValidCheck(student model)
        {
    if(!ModelState.IsValid)
    {

            Models.ViewModel.User model = new Models.ViewModel.User();
            model.Age = 12;
            model.Name = "Andy He";
            model.Email = "123";
            //TryValidateModel(model);
    }
         }


    try this code hope it resolve your problem


Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!