Guest User

Untitled

a guest
Aug 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. MonoRail BindObject() equivalent in ASP MVC3?
  2. public class MyModel
  3. {
  4. [Required]
  5. public string Name { get; set; }
  6.  
  7. public string Description { get; set; }
  8. }
  9.  
  10. [HttpPost]
  11. public ActionResult UpdateModel(bool? acceptedConditions)
  12. {
  13. var model = new MyModel();
  14. if (acceptedConditions ?? false)
  15. {
  16. if (TryUpdateModel(model))
  17. {
  18. //Do something when the model is valid
  19. }
  20. else
  21. {
  22. //Do something else when the model is invalid
  23. }
  24.  
  25. }
  26. return View();
  27. }
Add Comment
Please, Sign In to add comment