In my umbraco mvc project, I am trying to validate form with serverside validation.
Controller code:
public ActionResult BookRequest(BookRequest model)
{
if (ModelState.IsValid)
{
db.BookRequests.Add(model);
db.SaveChanges();
}
return View();
}
Model is,
public class BookRequest
{
public int Id { get; set; }
[Required(ErrorMessage = "Please enter your name")]
public string Name{ get; set; }
[Required(ErrorMessage = "Please enter your email")]
public string Email { get; set; }
}
Saving to database works fine. However, Validation is not showing up.
For that, it needs to return model from controller
return View(model);
when i add above code following error occurs,
The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'MvcApplication2.Models.BookRequest'.
Server side validation with umbraco mvc
Hello All,
In my umbraco mvc project, I am trying to validate form with serverside validation.
Controller code:
Model is,
Umbraco page
Partial View
Saving to database works fine. However, Validation is not showing up. For that, it needs to return model from controller
when i add above code following error occurs,
How can i solve this? Please help,
Thanks
I'd watch this video http://umbraco.tv/videos/developer/fundamentals/surface-controllers/introduction/
is working on a reply...