KhD
KhD

Reputation: 453

Firefox error - document.all is undefined (WebUIValidation.js)

I have created a simple ASP.Net application, where first page accepts an input and button click redirects the user to next page.
This is working in all the other browsers (IE, Opera, Safari), but nothing is happening in Firefox. There is no event generated on button click and no postback is happening.

A look into Firefox's error console showed me this error:

document.all is undefined
http://xxx/aspnet_client/system_web/2_0_50727/WebUIValidation.js
Line: 30
Line: 85

The functions where this error is encountered in WebUIValidation.js are:

function ValidatorHookupControlID(controlID, val) {
    if (typeof(controlID) != "string") {
        return;
    }
    var ctrl = document.all[controlID];

....

function ValidatorGetValue(id) {
    var control;
    control = document.all[id];

....

Please help!!!

Upvotes: 1

Views: 1490

Answers (2)

Lasse
Lasse

Reputation: 251

Try to change your code to use document.getElementById instead of document.all, like

function ValidatorHookupControlID(controlID, val) {
    if (typeof(controlID) != "string") {
        return;
    }
    var ctrl = document.getElementById(controlID);
    //.....
}

and...

function ValidatorGetValue(id) {
    var control = document.getElementById(id);
    //.....
}

Upvotes: 1

Zachary
Zachary

Reputation: 6532

Try adding this to your web.config <xhtmlConformance mode="Legacy"/> and reading this blog post for additional information on how/when client side validators are added to the page.

Upvotes: 1

Related Questions