Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.net MVC - IE9 has an extra item with an empty key in forms collection
    text
    copied!<p>I have a bit of an odd problem, and I'm struggling to track down the root cause...</p> <p>I have an ASP.net MVC site, and recently one of my colleagues started using IE9, and noticed a problem with one of the pages - it wasn't updating on click of save.</p> <p>I figured that this would probably be a script issue, as there is a fair bit of jQuery used on this page, and it may still be, but:</p> <p>If I submit this page in Chrome (or in IE8/7/6), then I get a forms collection with 11 items in it, as I would expect. If I submit the same page in IE9, I get an extra item at the end of the collection which has an empty string as key and an empty string as the value. This causes the call to UpdateModel() to not work (but not throw an exception) - none of these values are updated in my object, and the ModelState is still showing as valid.</p> <p>So far, I've only found this one page, but I'm curious if anybody might know what is causing this?</p> <hr> <p>Update 04/04/2011 - Narrowed down the culprit:</p> <p>I removed bits of code until this worked and narrowed it down to some code in my validation. I use the jQuery validate plugin, and had the following as a submit handler (some redaction performed on names...):</p> <pre><code>submitHandler: function (form) { var submitForm = true; var newValue, originalValue; newValue= $("#newValue").val(); originalValue= $("#originalValue").val(); if (newValue!= originalValue) { //affectedValues is an array populated at the top of the page. if ($.inArray(originalValue, affectedValues) != -1 &amp;&amp; $.inArray(newValue, affectedValues) == -1) { submitForm = confirm("Are you sure you want to do this"); } } if (submitForm) { form.submit(); } }, </code></pre> <p>Removing this from the code (which I can thankfully do, as it's a bit of legacy code), seems to make this work, my empty item in the forms collection is gone. If anybody has any idea why this might have been happening, that'd be great.</p>
 

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