id is null or not an object?

Dec 9, 2010 at 6:41 PM

Hey, I had this working before.....but due to some recent changes to my pages/database I am now getting an error when run in IE:  Microsoft JScript runtime error: 'id' is null or not an object.  Firefox seems to just be hiding the javascript error of elements is undefined.  Unravelling it abit, I seem to get the full error of "fieldContext.elements.0.id is null or not an object".

The error appears to be happening in the foolproof.getID function, though clicking ignore it will propagate to many of the other functions.

What id am I likely missing?  Any tips for this error?

 

Coordinator
Dec 9, 2010 at 6:47 PM

Can you give me some more details about the field that is having the error? For example: What is the data type? How is it being rendered - Texbox, CheckBox, ect?

Can you replicate the problem in a new project? If so, send it to me. 

Dec 9, 2010 at 7:02 PM
Still looking into this......but thought sharing my code might help....

Most data types are int and are stored as text boxes, some items are hidden……

 

Still

 

It’s further complicated in that I have a jquery-ui draggable row implementation around it (see: http://blog.stevensanderson.com/2008/12/22/editing-a-variable-length-list-of-items-in-aspnet-mvc/)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> Edit </title><link href="../../Content/Site.css" rel="stylesheet" type="text/css" /><link href="../../Content/jquery-ui-1.8.6.custom.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/Scripts/MicrosoftAjax.js"></script> <script type="text/javascript" src="/Scripts/MicrosoftMvcAjax.js"></script> <script type="text/javascript" src="/Scripts/MicrosoftMvcValidation.js"></script> <script type="text/javascript" src="/Scripts/MvcFoolproofValidation.min.js"></script> <script type="text/javascript" src="/Scripts/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/Scripts/jquery-ui-1.8.6.custom.min.js"></script> </head> <body> <div class="page"> <div id="header"> <div id="title"> <h1>Workout Manager</h1> </div> <div id="logindisplay"> Welcome <b>Mike</b>! [ <a href="/Account/LogOff">Log Off</a> ] </div> <div id="menucontainer"> <ul id="menu"> <li><a href="/">Home</a></li> <li><a href="/Routine">Routine</a></li> <li><a href="/Admin">Admin</a></li> </ul> </div> </div> <div id="main"> <h2>Sunday Routine</h2> <form action="/Routine/Edit/0" id="form0" method="post"><input name="__RequestVerificationToken" type="hidden" value="N5/915fLiWcAk7AtwaHWK1jzJRz7wfkf07IlvQ1z0q9rpQcs2ZrRYbj950XidzFPmAc377pR8u0QR1t9zlKwxTsvhtupc8CTrDKWGFZeMtKVkEQEHH/fQeQBPgUbOiItVXm0s542DBKxeMUp5KjPXw==" /> <div class="validation-summary-valid" id="validationSummary"><span>Save was unsuccessful. Please correct the errors and try again.</span> <ul><li style="display:none"></li> </ul></div> <fieldset> <legend>Exercises</legend> <div id="items"> <table width="100%" style="border: 0; padding: 0.3em; background-color:White; "> <tr style="border:0; border-bottom: 1px dashed silver; border-top: 1px dashed silver; cursor: move;"> <input type="hidden" name="routineEntry.index" value="6" /> <input id="routineEntry_6__CustomerRoutineID" name="routineEntry[6].CustomerRoutineID" type="hidden" value="6" /> <td style="border-width: 0"> <a href="/Exercise/Details/0">Abdominal Barbell Rollouts</a> </td> <td align="right" style="border-width: 0; margin-right: 50px"> <br /> <input id="routineEntry_6__Duration" name="routineEntry[6].Duration" type="hidden" value="0" /> <input id="routineEntry_6__DurationMax" name="routineEntry[6].DurationMax" type="hidden" value="0" /> Sets: <input class="small-input" id="routineEntry_6__Sets" name="routineEntry[6].Sets" type="text" value="3" /> <span class="field-validation-valid" id="Sets_validationMessage">*</span> to <input class="small-input" id="routineEntry_6__SetsMax" name="routineEntry[6].SetsMax" type="text" value="3" /> <span class="field-validation-valid" id="SetsMax_validationMessage">*</span> <br /> Reps: <input class="small-input" id="routineEntry_6__Reps" name="routineEntry[6].Reps" type="text" value="3" /> <span class="field-validation-valid" id="Reps_validationMessage">*</span> to <input class="small-input" id="routineEntry_6__RepsMax" name="routineEntry[6].RepsMax" type="text" value="5" /> <span class="field-validation-valid" id="RepsMax_validationMessage">*</span> <br /><br /> </td> <td width="50px" align="right" style="border-width: 0"> <img alt="X" src="../../Content/Images/delete.png" onclick="deleteContainer(event)" onmouseover="this.style.cursor='hand'" /> </td> </tr> </table> </div> <p align="center"><i>Drag exercises to change their order.</i></p> <p> <input type="submit" name="submitButton" value="Save" /> <input type="submit" name="submitButton" value="Save &amp; Add Exercise" /> <input type="submit" name="submitButton" value="Refresh" /> </p> </fieldset> </form><script type="text/javascript"> //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({"Fields":[{"FieldName":"Sets","ReplaceValidationMessageContents":false,"ValidationMessageId":"Sets_validationMessage","ValidationRules":[{"ErrorMessage":"Sets must be positive","ValidationParameters":{"minimum":0,"maximum":2147483647},"ValidationType":"range"},{"ErrorMessage":"You must specify a number of sets","ValidationParameters":{},"ValidationType":"required"},{"ErrorMessage":"The field Sets must be a number.","ValidationParameters":{},"ValidationType":"number"}]},{"FieldName":"SetsMax","ReplaceValidationMessageContents":false,"ValidationMessageId":"SetsMax_validationMessage","ValidationRules":[{"ErrorMessage":"Maximum sets must be greater than or equal to starting sets","ValidationParameters":{"DependentProperty":"Sets","Operator":"GreaterThanOrEqualTo"},"ValidationType":"Is"},{"ErrorMessage":"Maximum sets must be positive","ValidationParameters":{"minimum":0,"maximum":2147483647},"ValidationType":"range"},{"ErrorMessage":"You must specify a maximum number of sets","ValidationParameters":{},"ValidationType":"required"},{"ErrorMessage":"The field SetsMax must be a number.","ValidationParameters":{},"ValidationType":"number"}]},{"FieldName":"Reps","ReplaceValidationMessageContents":false,"ValidationMessageId":"Reps_validationMessage","ValidationRules":[{"ErrorMessage":"Reps must be positive","ValidationParameters":{"minimum":0,"maximum":2147483647},"ValidationType":"range"},{"ErrorMessage":"You must specify a number of reps","ValidationParameters":{},"ValidationType":"required"},{"ErrorMessage":"The field Reps must be a number.","ValidationParameters":{},"ValidationType":"number"}]},{"FieldName":"RepsMax","ReplaceValidationMessageContents":false,"ValidationMessageId":"RepsMax_validationMessage","ValidationRules":[{"ErrorMessage":"Maximum reps must be greater than or equal to starting reps","ValidationParameters":{"DependentProperty":"Reps","Operator":"GreaterThanOrEqualTo"},"ValidationType":"Is"},{"ErrorMessage":"Maximum reps must be positive","ValidationParameters":{"minimum":0,"maximum":2147483647},"ValidationType":"range"},{"ErrorMessage":"You must specify a maximum number of reps","ValidationParameters":{},"ValidationType":"required"},{"ErrorMessage":"The field RepsMax must be a number.","ValidationParameters":{},"ValidationType":"number"}]}],"FormId":"form0","ReplaceValidationSummary":true,"ValidationSummaryId":"validationSummary"}); //]]> </script><a href="/Routine">Back to Full Routine</a> <script type="text/javascript"> function deleteContainer(evt) { evt = evt || window.event; var target = evt.target || evt.srcElement; target.parentNode.parentNode.parentNode.removeChild(target.parentNode.parentNode); } $(function (evt) { $("#items").sortable({ axis: "y" }); }); </script> <div id="footer"> </div> </div> </div> </body> </html>