What could be causing this JavaScript error? <p>I'm modifying an ASP.NET webform that loads a user control. In the user control there is JavaScript that is generating an error. The error is:</p> <blockquote> <p>JavaScript runtime error: The value of the property 'GetFirstItineraryObjects' is null or undefined, not a Function object</p> </blockquote> <p>This is a call in a list of function calls containing:</p> <pre><code>GetFirstItineraryObjects(); </code></pre> <p>And yes, when I examine the page source when it renders (after blowing past the JS error), this function is indeed there. I did wonder if the one line in this function that I modified might be causing the problem, so I commented it out. But the error still occurs.</p> <p>What can cause a JavaScript runtime error of this nature?</p> <p>I don't think this will help much, but here's the code which adds the JavaScript. Note that the entire page is rendered and sent to the browser before the browser can possibly execute any JavaScript in the page (this is for @Arwind).</p> <pre><code>clientScriptKey = "SetOriginalMileageObjectValues"; clientScriptText = string.Empty; if (!clientScript.IsClientScriptBlockRegistered(clientScriptType, clientScriptKey)) { clientScriptText = "function GetFirstItineraryObjects()" + Environment.NewLine; clientScriptText += " {" + Environment.NewLine; // a bunch of code clientScriptText += " }" + Environment.NewLine + Environment.NewLine; clientScript.RegisterClientScriptBlock(clientScriptType, clientScriptKey, clientScriptText, true); } clientScriptKey = "CreateMileageDataOldValues"; clientScriptText = string.Empty; if (!clientScript.IsClientScriptBlockRegistered(clientScriptType, clientScriptKey)) { clientScriptText = "GetFirstItineraryObjects();" + Environment.NewLine; clientScriptText += "GetFromLocationOldValues();" + Environment.NewLine; clientScriptText += "GetToLocationOldValues();" + Environment.NewLine; clientScriptText += "GetStartDateOldValues();" + Environment.NewLine; clientScript.RegisterStartupScript(clientScriptType, clientScriptKey, clientScriptText, true); } </code></pre> <p>Upon further examination, all four of those function calls (not just GetFirstItineraryObjects) throw the same JavaScript error, AND the functions do exist at runtime.</p>