Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When your model is invalid, you don't actually return it with it's validation errors. Then, you do this:</p> <pre><code>@Html.ValidationMessageFor(model =&gt; model.KeyActiveMg) </code></pre> <p>but there is no Validation Message for anything. You returned a brand new view with a blank Model. Instead, you should return your invalid model to the view, like such:</p> <pre><code>return View(rawvalues); </code></pre> <p><strong>UPDATE</strong></p> <p>Your controller should look like this:</p> <pre><code>public ActionResult Create() { return View(new RawValues()); } [HttpPost] public ActionResult Create(RawValues model) { if (ModelState.IsValid) { // Do stuff } else { return View(model); } } </code></pre> <p>Your view seems fine, so it should work from here.</p> <p>If you're talking about client side validation, you need to reference the necessary JS files. They should be already preconfigured in your Bundle config. You just need to add to your view:</p> <pre><code>@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") @Scripts.Render("~/bundles/jqueryval") </code></pre> <p>Just to make sure, your BundleConfig class that sits in the <code>App_Start</code> folder should have these:</p> <pre><code>bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include( "~/Scripts/jquery-ui-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); </code></pre>
    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. This table or related slice is empty.
    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