1. register the asyncpostbackerror event of scriptmanager, implement it on the server, and throw an exception that has been processed (based on whether the event is null, you may need to throw e. exception or e. exception. innerexception)
2. The client uses js to respond. sys. webforms. pagerequestmanager. getinstance (). add_endrequest (endrequesthandler); add a handler.
3. Implement endrequesthandler. The error message is basically in the second parameter "args,
4. This is done now. As no ready-made documents are found on the Internet (leave a message if any), what is going on in this args?
There are many contents. I 'd like to write out the enumeration method first.
Sys. webforms. pagerequestmanager. getinstance (). add_endrequest (endrequesthandler );
Function endrequesthandler (sender, args ){
// If (args. get_error ()! = Undefined) {alert (args. get_error (). message. replace (/. * exception:/, ''); args. set_errorhandled (true );}
If (args. get_error ()! = Undefined ){
Var members = 'args' members are: nn ';
For (var I in args ){
Members + = 'T' + I;
Var ai = eval ("args." + I );
If (typeof ai = "function "){
Try {
Members + = "()";
Ai = eval ("args." + I + "()");
} Catch (err ){
Members + = "not implement n ";
Continue;
}
}
Members + = 'n ';
If (typeof ai = "string") continue;
For (var t in ai ){
Members + = 'TT' + t;
If (typeof ai = "function ")
Var ait = eval ("args." + I + "()." + t );
Else
Var ait = eval ("args." + I + "." + t );
If (typeof ait = "function "){
Try {
Members + = "()";
Ait = eval ("args." + I + "." + t + "()");
} Catch (err ){
Members + = "not implement n ";
Continue;
}
}
Members + = "n ";
If (typeof ait = "string") continue;
For (var m in ait ){
Members + = 'ttt' + m + 'n ';
}
}
}
Document. write ("<textarea style = 'width: 1000px; height: 600px; '>" + members + "</textarea>"); // If members is displayed, process it by yourself
Args. set_errorhandled (true );
}
}
1 2