Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
'Validators.length' is null or not an object error in scriptresource.axd
posted

Hi

We have an urgent issue with the WebDataGrids in IE 8 (version 8.0.6001.18702) on XP.  We are using IG controls 13.1.20131.2107 with .NET 4.0

It occurs on pages which have a validator on one/more fields of a WebDataGrid but does not happen consistently.  If we simply swap between two pages using our menu it will happen on one of the pages after a while - sometimes the first time we swap, other times it takes 3 or 4 clicks between the pages.

The error occurs on the last line of this function from ScriptResource.axd file and happens because control.Validators is null.

function ValidatorHookupControl(control, val) {
    if (typeof(control.tagName) != "string") {
        return;  
    }
    if (control.tagName != "INPUT" && control.tagName != "TEXTAREA" && control.tagName != "SELECT") {
        var i;
        for (i = 0; i < control.childNodes.length; i++) {
            ValidatorHookupControl(control.childNodes[i], val);
        }
        return;
    }
    else {
        if (typeof(control.Validators) == "undefined") {
            control.Validators = new Array;
            var eventType;
            if (control.type == "radio") {
                eventType = "onclick";
            } else {
                eventType = "onchange";
                if (typeof(val.focusOnError) == "string" && val.focusOnError == "t") {
                    ValidatorHookupEvent(control, "onblur", "ValidatedControlOnBlur(event); ");
                }
            }
            ValidatorHookupEvent(control, eventType, "ValidatorOnChange(event); ");
            if (Page_TextTypes.test(control.type)) {
                ValidatorHookupEvent(control, "onkeypress",
                    "event = event || window.event; if (!ValidatedTextBoxOnKeyPress(event)) { event.cancelBubble = true; if (event.stopPropagation) event.stopPropagation(); return false; } ");
            }
        }
        control.Validators[control.Validators.length] = val;
    }
}

NOTES:

  • The validators work perfectly well on the grid if we actually make changes to the data.
  • This error occurs without changing any data.  Ie, we load the page, then we simply click a menu to go to another page.  No data is changed in the grid.
  • This only happens in IE8.  We can click between the pages 100 times in IE 9 and it does not occur (yes, I actually did this)

There is an "IF" block above the line which has the problem checking if the object is undefined - if (typeof(control.Validators) == "undefined") should this be also checking whether control.Validators == null??

Are we able to edit this function ourselves somehow to add this to the IF statement to see if it fixes the problem?

Any help much appreciated

Marcus

  • 49378
    posted

    Hello Marcus,

    Thank you for your post.

    So far I am unable to replicate the described behavior, however please note that the javascript exception mentioned is thrown from ASP.NET's clitnside validation scripts, not the WebDataGrid scripts. Therefore it may be helpful to try and redefine the ValidatorHookupControl in order to incorporate the null check mentioned. This can be done by placing the new definition for the function just before the closing of the form or body tags on the page.

    Hope this helps. Please do not hesitate to contact me if you have any questions.