Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been using <a href="http://jquery.malsup.com/form/">malsup's jQuery form plugin</a> for a while for this purpose. I'm honestly not familiar with AjaxHelper, but does look like it'll do what you're looking for. As far as doing both client and server side validation, that should all happen mostly automatically as long as you're using model binding and the attributes from the System.DataAnnotations namespace.</p> <pre><code>public class MyModel { [Required(ErrorMessage = "Please enter your name")] public String Name { get; set; } [Required(ErrorMessage = "Please enter your email")] public String Email { get; set; } [Required(ErrorMessage = "Please enter a rating")] [Range(1, 5, ErrorMessage = "The rating must be between 1 and 5")] public Int32 Rating { get; set; } } [HttpPost] public ActionResult Index(MyModel myModel) { if(ModelState.IsValid) { // good to go, put it in the DB or whatever you need to do } else { return View(model); // return the user back to the page, ModelState errors can be viewed using Html.ValidationSummary() or individual Html.ValidationMessageFor() calls } } </code></pre> <p>If you're doing your own custom server-side validation, you can either create your own custom validation attribute by creating an attribute that implements ValidationAttribute, or just add validation errors by calling ModelState.Errors.Add() (or something around there, I don't have a reference handy)</p> <p>For client side, MVC will generate clientside validation for you based on the DataAnnotations attributes on your model.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload