5
Reply

In Server how to check whether model has error or not in ASP.Net MVC?

Ritesh Singh

Ritesh Singh

Aug 19, 2016
485
0

    With the help of Data Annotation we check the model has error or not Example : public ActionResult Index(Models model){if (ModelState.IsValid) //this provide bool result for model is valid or not{ViewBag.Name = model.Name;ViewBag.Email = model.Email;}return View(model);}

    Shivam Mishra
    April 04, 2017
    0

    With the help of Data Annotation we check the model has error or not Example : public ActionResult Index(Models model){if (ModelState.IsValid) //this provide bool result for model is valid or not{ViewBag.Name = model.Name;ViewBag.Email = model.Email;}return View(model);}

    Shivam Mishra
    April 04, 2017
    0

    With the help of Data Annotation we check the model has error or not Example : public ActionResult Index(Models model){if (ModelState.IsValid) //this provide bool result for model is valid or not{ViewBag.Name = model.Name;ViewBag.Email = model.Email;}return View(model);}

    Shivam Mishra
    April 04, 2017
    0

    With the help of Data Annotation we check the model has error or not Example : public ActionResult Index(Models model){if (ModelState.IsValid) //this provide bool result for model is valid or not{ViewBag.Name = model.Name;ViewBag.Email = model.Email;}return View(model);}

    Shivam Mishra
    April 04, 2017
    0

    With the help of Data Annotation we check the model has error or not Example : public ActionResult Index(Models model){if (ModelState.IsValid) //this provide bool result for model is valid or not{ViewBag.Name = model.Name;ViewBag.Email = model.Email;}return View(model);}

    Shivam Mishra
    April 04, 2017
    0