title: MVC Bootstrap modal show validation result
body: <p>The problem:</p>
  
  <p>I want to preform submit to form that is in modal and if validation faild to get the error message on the modal.</p>
  
  <p>I'm using ajax validation (jQuery) as detailed <a href="https://stackoverflow.com/questions/14005773/use-asp-net-mvc-validation-with-jquery-ajax">here</a></p>
  
  <p>Is there an elegant way to perform submit but on faild stay at modal to show error message?</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult Create(Cam c)
      {
          ViewBag.id = c.id;
  
          using (Entities db = new Entities())
          {
              if (ModelState.IsValid)
              {
                  db.camp.Add(c);
                  db.SaveChanges();
                  return RedirectToAction("Index", new { id = c.id });
              }
  
          }
          return null;
      }
  </code></pre>
  
  <p><strong>Client:</strong></p>
  
  <pre><code>@using (Html.BeginForm("Create", "Camp", FormMethod.Post, new { model = 
  Model }))
  {
  @Html.AntiForgeryToken()
  
  &lt;dt&gt;
              name:
          &lt;/dt&gt;
          &lt;dd&gt;
              @Html.TextBoxFor(model =&gt; model.name, new { @class = "form-control", @placeholder = "name", @id = "txtVenueID", style = "width:150px" })
          &lt;/dd&gt;
  
          &lt;dd&gt;
              @Html.ValidationMessageFor(model =&gt; model.name)
          &lt;/dd&gt;
  &lt;div class="modal-footer "&gt;
  &lt;button type="button" class="btn btn-default" data-
  dismiss="modal"&gt;Close&lt;/button&gt;
  &lt;button type="submit" class="btn btn-primary"&gt;Save&lt;/button&gt;
  &lt;/div&gt;
  }
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public partial class Cam
  {
  
      [Display(Name = "Name")]
      [Required(ErrorMessage = "Require {0}")]
      string name { get; set; }
  }
  </code></pre>