Serious problem with trigger() and ASP.NET client side validation

Serious problem with trigger() and ASP.NET client side validation


When manually triggering a "change" event on a text box which has
ASP.NET client-side validation, Internet Explorer will generate a
Javascript error. It works fine in FireFox.
I'll explain the reason:
in the jQuery code, the trigger() function contains the following:
(line 1730 in the uncompressed .js file)
==================
// Handle triggering native .onfoo handlers
if ( !fn && element["on"+type] && element["on"+type].apply( element,
data ) === false )
val = false;
==================
This causes problems with ASP.NET client side validation. The ASP.NET-
generated javascript method ValidateHookupEvent() does something
really terrible:
==================
function ValidatorHookupEvent(control, eventType, functionPrefix) {
var ev;
eval("ev = control." + eventType + ";");
if (typeof(ev) == "function") {
ev = ev.toString();
ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
}
else {
ev = "";
}
var func;
if (navigator.appName.toLowerCase().indexOf('explorer') > -1) {
func = new Function(functionPrefix + " " + ev);
}
else {
func = new Function("event", functionPrefix + " " + ev);
}
eval("control." + eventType + " = func;");
}
==================
Check out the Function() constructor calls at the end of the method.
If Internet Explorer is detected, the event handler function is
created WITHOUT the event parameter. When jQuery tries to call the
event handler, it passes the event object to the event handler, but it
is not passed on, which creates problems in the ASP.NET client side
validation event handlers.
The result is that the change() trigger will always generate a
javascript error in IE (when client side validation is enabled)