Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Is the form posting? If not you may have a validation rule that's being violated but you may not see the error message if you don't have Html.ValidationSummary or Html.ValidationMessageFor enabled.</p> <p>**EDIT: </p> <p>I tried with the latest version of jQuery (1.6.4) and with 1.6.2 with this code without any issues. </p> <p>controller code</p> <pre><code>public class TestViewModel { [Required] public string textTest { get; set; } [Required] public int intTest { get; set; } } public class HomeController : Controller { public ActionResult Index() { return View(new TestViewModel()); } [HttpPost] public ActionResult Index(TestViewModel model) { if (ModelState.IsValid) { return Redirect("http://www.yahoo.com"); } return View(model); } </code></pre> <p>}</p> <p>markup</p> <pre><code>@model MvcApplication39.Controllers.TestViewModel @{ ViewBag.Title = "Index"; } &lt;h2&gt;ViewBag.Title&lt;/h2&gt; &lt;script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;TestViewModel&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.textTest) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.textTest) @Html.ValidationMessageFor(model =&gt; model.textTest) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.intTest) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.intTest) @Html.ValidationMessageFor(model =&gt; model.intTest) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } &lt;div&gt; @Html.ActionLink("Back to List", "Index") &lt;/div&gt; </code></pre>
 

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