ASP.NET/Javascript error. Sporadically occurs, 'length is null or not an object'

This one has me perplexed. I have a web app that does many functions, but the part that it is bombing out is when doing a Search function which calls a webservice and returns results back from DB2.

The odd thing, is the error doesn’t always occur and only seems to occur when accessing my web app through a vip(which is on a load balancer, round-robin on 2 IIS Servers). The error doesn’t come up when accessing the web app when using the direct URL for one of the servers.

  • <select> for <select> c# to javascript
  • Is there any way to 'hide' a JavaScript file from IntelliSense in Visual Studio 2008?
  • how to Add the days using Dropdown list?
  • How can i move items from one Listbox to another in ASP MVC 4?
  • Re-center Modal Popup with Javascript
  • How to call two functions on single event. one as a javascript function other a server side function
  • Which leads me to believe, something with my web.config?

    Also I searched my javascript code, and I don’t use Length anywhere.

    Please help, i’ve been banging my head against the wall on this.

    UPDATED with code(I included the neccessary code below, omitted the rest):


    function ValidateSearch() {

    if (Page_ClientValidate("TransSearch") == true) {              
                    return true;
                else {
                    return false;


    function ShowWait() {

        target = document.getElementById('progress');
    //This calls spinner.js from github


    function searchComplete() {

    //clear previous search textboxes
    document.getElementById('<%# txtEmail.ClientID %>').value = "";
        document.getElementById('<%# txtPhone.ClientID %>').value = "";



        <div class="searchlabel">
        <label>Email Address</label><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator runat="server" ID="EmailReq"  
                    ControlToValidate="txtEmail"  ValidationGroup="TransSearch"
                ErrorMessage="<b>Required Field Missing</b><br />Email is required." />  
            <asp:ValidatorCalloutExtender runat="Server" ID="EmailReqE"  
                HighlightCssClass="validatorCalloutHighlight"  />
    <div class="searchlabel">
            <label>Phone</label><asp:TextBox ID="txtPhone" runat="server" Font-Size="Medium"></asp:TextBox>
                <asp:RequiredFieldValidator runat="server" ID="PhnReq"  
                    ControlToValidate="txtPhone"  ValidationGroup="TransSearch"
                    ErrorMessage="<b>Required Field Missing</b><br />Phone is required." />  
                <asp:ValidatorCalloutExtender runat="Server" ID="PhnReqE"  
                    HighlightCssClass="validatorCalloutHighlight" /> 
    <asp:Button ID="btnSearch" runat="server" Text="Search" Width="90px" OnClientClick="return ValidateSearch();" OnClick="Search_Click" />


    public void Search_Click(Object sender, EventArgs e)

    //passes search text to webservice
    //fills gridview with returned data
    //lastly calls javascript function to stop spinner
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "searchComplete", "<script type='text/javascript'>searchComplete();</script>", false);


  • how to bind javascript function with OnClientClick event with Eval?
  • login control error
  • How to use and phantomjs to take a screen shot of a page and return it to the client
  • Javascript onclick function on div works only in IE
  • Preventing multiple JavaScript scripts loading in Asp.Net Core ViewComponents
  • Show Modal Dialog/Confirmation Box Based on User Input in Code Behind/
  • One Solution collect form web for “ASP.NET/Javascript error. Sporadically occurs, 'length is null or not an object'”

    Maybe your javascript function is not getting the textbox you are providing it with.

    document.getElementById('<%# txtEmail.ClientID %>').value

    Check the value using:

    alert(document.getElementById('<%# txtEmail.ClientID %>').value ) 

    if it is returning value. This maybe the reason your spinner.stop(); is not working.

    Use alert to see if it is entering your function. I use it every time I am stuck in javascript . It helps me to find after which line the function is giving error.