开发者

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

开发者 https://www.devze.com 2023-03-16 00:58 出处:网络
I have created a simple ASP.Net application, where first page accepts an input and button click redirects the user to next page.

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 开发者_如何学JAVAme 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!!!


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.


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);
    //.....
}
0

精彩评论

暂无评论...
验证码 换一张
取 消