3

I used the package manager console to install these two packages: foolproof & MvcExtentions.Foolproof. I included the foolproof script files in my bundle config (see below).

Note that I didn't implement any foolproof code yet, I only installed the pacakges and included the script files and then ran the app.

I'm getting the following clientside error:

MvcFoolproofValidation.js: Uncaught ReferenceError: Sys is not defined

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
     "~/Scripts/jquery-{version}.js",
     "~/Scripts/jquery-ui-{version}.js",
     "~/Scripts/jquery.unobtrusive*",
     "~/Scripts/jquery.validate*",
     "~/Scripts/MvcFoolproofJQueryValidation.js",
     "~/Scripts/mvcfoolproof.unobtrusive.js",
     "~/Scripts/MvcFoolproofValidation.js"));

which renders as: (if its of any consequence)

<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/jquery-ui-1.10.3.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/MvcFoolproofJQueryValidation.js"></script>
<script src="/Scripts/mvcfoolproof.unobtrusive.js"></script>
<script src="/Scripts/MvcFoolproofValidation.js"></script>
Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Swifty
  • 1,422
  • 2
  • 18
  • 38

2 Answers2

4

The problem is because the order is incorrect. I had the same problem, but i resolve doing this order:

Bundles:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
    "~/Scripts/jquery.validate*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
    "~/Scripts/bootstrap.js",
    "~/Scripts/respond.js",
    "~/Scripts/jquery.validate.min.js",
    "~/Scripts/jquery.validate.unobtrusive.min.js",
    "~/Scripts/blur.js"));

bundles.Add(new ScriptBundle("~/bundles/mvcfoolproof").Include(
    "~/Scripts/MicrosoftAjax.js",
    "~/Scripts/MicrosoftMvcAjax.js",
    "~/Scripts/MicrosoftMvcValidation.js",
    "~/Scripts/MvcFoolproofJQueryValidation.min.js",
    "~/Scripts/MvcFoolproofValidation.min.js",
    "~/Scripts/mvcfoolproof.unobtrusive.min.js"));

The View:

@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/mvcfoolproof")

The render:

 <script src="/Scripts/jquery-ui-1.11.1.js"></script>
 <script src="/Scripts/jquery.validate.js"></script>
 <script src="/Scripts/jquery.validate.unobtrusive.js"></script>
 <script src="/Scripts/MicrosoftAjax.js"></script>
 <script src="/Scripts/MicrosoftMvcAjax.js"></script>
 <script src="/Scripts/MicrosoftMvcValidation.js"></script>
 <script src="/Scripts/MvcFoolproofJQueryValidation.min.js"></script>
 <script src="/Scripts/MvcFoolproofValidation.min.js"></script>
 <script src="/Scripts/mvcfoolproof.unobtrusive.min.js"></script>

And... the problem its gone.

See the documentation for check this order here.

zx485
  • 28,498
  • 28
  • 50
  • 59
Ali Briceño
  • 1,096
  • 2
  • 17
  • 44
  • Glad to help pal... Reggrads – Ali Briceño May 07 '15 at 15:46
  • 1
    Where is "Sys" coming from? I'm trying to set this up using RequireJS and I'm having some issues because of the order I'm guessing. – muttley91 Sep 25 '15 at 15:32
  • @muttley91 When you have a ScriptManager on a page (as this case), ASP.NET AJAX will render a few script tags to load the various ASP.NET AJAX Scripts, and some inline script to get everything initialized and running. If you view source on the page as rendered by your browser, you should see something like this: – Ali Briceño Dec 19 '15 at 15:51
  • just for note `MicrosoftAjax.js` and `MicrosoftMvcAjax.js` and `MicrosoftMvcValidation.js` has been deprecated here is the source http://stackoverflow.com/questions/8782697/ – Hakan Fıstık Dec 21 '16 at 10:05
1

You're not loading all 3 scripts are you? You are only supposed to load:

mvcfoolproof.unobtrusive.js AND (MvcFoolproofJQueryValidation.js OR MvcFoolproofValidation.js)

If you are loading all 3 scripts, can you stop loading the MvcFoolproofValidation.js script.

If you are just using mvcfoolproof.unobtrusive.js and MvcFoolproofValidation.js, can you swap to mvcfoolproof.unobtrusive.js and MvcFoolproofJQueryValidation.js

kiran
  • 11
  • 1