An example scenario:
示例场景:
- User performs an update, for example a drag & drop. This is an ajax request.
- Server-side code cannot validate the update or the operation just fails. An exception is thrown.
- A reasonable error message should be shown to the user.
用户执行更新,例如拖放。这是一个ajax请求。
服务器端代码无法验证更新或操作失败。抛出异常。
应向用户显示合理的错误消息。
How should I communicate the exception to the client side and show the error message in a div message box?
我应该如何将异常传达给客户端并在div消息框中显示错误消息?
The message should be shown after the fact. Sometimes it is possible to prevent errors in client-side code but I'm not concerned about this.
事后应该显示该消息。有时可以防止客户端代码中的错误,但我并不关心这一点。
With traditional data binding in the code behind file I can show a label after an error condition. But if the Ajax control is connected to a provider class specified in the aspx, I don't see how this would be possible. Only option I can think of is to catch server-side exceptions in client-side code. Is this possible?
使用代码隐藏文件中的传统数据绑定,我可以在错误条件之后显示标签。但是如果Ajax控件连接到aspx中指定的提供者类,我不知道这是如何实现的。我能想到的唯一选择是在客户端代码中捕获服务器端异常。这可能吗?
I'm using Telerik RadControls for ASP.NET Ajax.
我正在使用Telerik RadControls进行ASP.NET Ajax。
1 个解决方案
#1
0
You can try adding the error,handler directly in Ajax framework like this:
您可以尝试直接在Ajax框架中添加错误,处理程序,如下所示:
http://encosia.com/how-to-improve-aspnet-ajax-error-handling/
#1
0
You can try adding the error,handler directly in Ajax framework like this:
您可以尝试直接在Ajax框架中添加错误,处理程序,如下所示:
http://encosia.com/how-to-improve-aspnet-ajax-error-handling/