3

I am developing a web page using ASP.NET unobtrusive validation. When I view my page in IE9 using the default IE9 Browser Mode, the page works as expected. However, when I simply switch the Browser Mode from IE9 to IE8, I receive the following JavaScript error as the page reloads:

"Error: 'Page_Validators' is undefined"

Unobtrusive validation requires a ScriptResourceMapping named "jquery". That is in place. I am also using a <script> tag in the master page to include jquery on all pages.

Also, I have an empty tag on the master page to enable my user control to load other javascript via a ScriptManagerProxy tag in the control's markup.

Relevant markup on master page:

<%@ Master Language="C#" AutoEventWireup="true" Inherits="Site" Codebehind="Site.master.cs" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<script src="Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>

<title></title>

<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>

</head>

Any ideas?

threadster
  • 418
  • 5
  • 18
  • Are they undefined !? or you try to use them before the fully load of the page aka, before loading that script part ? – Aristos Jan 23 '13 at 15:28
  • I figured out that it is this call that is causing the error: `// disable validators $('#CoappPersonalInformationForm.failureNotification').each(function () { ValidatorEnable(this, false); });` – threadster Jan 23 '13 at 15:45
  • Try to call it after the page is fully loaded to see if the problem solved. – Aristos Jan 23 '13 at 15:48
  • un-rendered ASP code doesn't help with debugging browser issues. It certainly doesn't help us with working out the problem. It might help if you look at the rendered HTML/JS code that the browser actually sees. – SDC Jan 23 '13 at 15:55
  • The `ValidatorEnable(this, false);` call is issued from jquery's document ready function. – threadster Jan 23 '13 at 15:56

1 Answers1

3

It is possible that you call it before is loaded from the JavaScript files. Try to warp it with the ready

$(document).ready(function() {
   $('#CoappPersonalInformationForm.failureNotification').each(function () 
     {
        ValidatorEnable(this, false); 
     });
});
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • Thanks. Tried it. Didn't work. The function Configure_CoAp() was already being called from $() already. I tried your suggestion hoping that wrapping the the call in yet another document ready that it would somehow get queued up after the Page_Validators array was populated. – threadster Jan 23 '13 at 17:43
  • @threadster Did the function in general loaded by javascript files, or maybe for some reason is not ? – Aristos Jan 23 '13 at 18:46