13/05/2009
在code-behind throw exception
如果是ASP.NET 2.0用throw是可自动弹出js的MsgBox,但到了ASP.NET3.5,用throw 是会在IE内报js错误的.
搜索到了这个错误:UpdatePanel alert not
showing when server exception thrown http://forums.asp.net/t/1382061.aspx
解决方案:
说明了ajax for
.net 3.5 和ajax 1.0的区别。
- In ASP.NET Ajax 1.0, the server-side exception object is serialized into JSON. The JSON is sent to the client, which displays the exception’s message property in an alert box.
- In ASP.NET Ajax for .NET 3.5, the server-side exception is still serialized into JSON and the JSON is still sent to the client. However, instead of displaying the exception’s message property in an alert box – a presumptuous design decision, if you want my opinion – the client throws the exception, which gives you the opportunity to handle it on the client side as you please.