1,注册scriptmanager的asyncpostbackerror事件,并在服务器实现它,并抛出被处理过的异常(根据是否为null,可能需要抛出e.exception或e.exception.innerexception)
2,客户端用js来响应,sys.webforms.pagerequestmanager.getinstance().add_endrequest(endrequesthandler);添加处理程序
3,实现endrequesthandler,错误信息基本在第二个参数"args“里面,
4,此时已经完成,由于网上没搜到现成文档(有的话请留言),这个args里面到底有什么经过我的枚举,暂列如下
内容比较多,我还是先把枚举的方法写出来吧
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 = 'the '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("");//members如果显示请自行处理
args.set_errorhandled(true);
}
}
the 'args' members are:
_errorhandled
_error
message
name
https教程tatuscode
format
localeformat
_toformattedstring
stack
filename
linenumber
format
localeformat
_toformattedstring
popstackframe()
_dataitems
_response
_webrequest
_url
_headers
_body
_usercontext
_httpverb
_executor
_invokecalled
_timeout
_events
add_completed
remove_completed
completed
_get_eventhandlerlist
get_url
set_url
get_headers
get_httpverb
set_httpverb
get_body
set_body
get_usercontext
set_usercontext
get_executor
set_executor
get_timeout
set_timeout
getresolvedurl
invoke
constructor
_resultobject
_xmlhttprequest
dispatchevent
removeeventlistener
onreadystatechange
open
readystate
setrequestheader
send
status
responsetext
channel
responsexml
statustext
abort
getallresponseheaders
getresponseheader
sendasbinary
overridemimetype
multipart
mozbackgroundrequest
withcredentials
upload
onuploadprogress
onabort
onerror
onload
onloadstart
onprogress
getinterface
_responseavailable
_timedout
_timer
_aborted
_started
_onreadystatechange()
_cleartimer()
_ontimeout()
get_timedout()
get_started()
get_responseavailable()
get_aborted()
executerequest() not implement
getresponseheader() not implement
getallresponseheaders() not implement
get_responsedata() not implement
get_statuscode() not implement
get_statustext() not implement
get_xml() not implement
abort()
constructor()
get_webrequest()
_set_webrequest()
get_object() not implement
get_dataitems()
get_error()
message
name
httpstatuscode
stack
filename
linenumber
popstackframe
get_errorhandled()
set_errorhandled() not implement
get_response()
_webrequest
_resultobject
_xmlhttprequest
_responseavailable
_timedout
_timer
_aborted
_started
_onreadystatechange
_cleartimer
_ontimeout
get_timedout
get_started
get_responseavailable
get_aborted
executerequest
getresponseheader
getallresponseheaders
get_responsedata
get_statuscode
get_statustext
get_xml
abort
constructor()
callbasemethod
getbasemethod
getbasetype
getinterfaces
getname
implementsinterface
inheritsfrom
initializebase
isimplementedby
isinstanceoftype
registerclass
registerinterface
resolveinheritance
registerenum
get_webrequest
_set_webrequest
get_object
constructor() not implement