Thursday, 15 April 2010

asp.net - UpdatePanel Exception Handling -


Where I am implementing in the AppNet Web application in UpdatePanels, where I am creating, they cause javascript Error on page with some high level error output available in the warning. It is fine for development, but as soon as the system is in production, it is clearly not good for many reasons. I try to control the javascript error, I can pass troublesome activities with catch etc. But in some cases, I want to take action on main page etc. to support the user experience.

How can I be proud to provide an uninterrupted and javascript error free implementation in the update panels?

You can use a combination of

here are some resources that you can use You have to help. In order to solve this problem, the AsyncPostBackError event on the ScriptManager (Server Side) and EndRequest event on PageRequestManager (client-side) to handle the side-side errors of the server completely. Here is a simple example:

  // server-side protected void ScriptManager1_AsyncPostBackError (Object Sender, AsyncPostBackErrorEventArgs E) {ScriptManager1.AsyncPostBackErrorMessage = "There was an error during the request:" + e.exception.Message; } // client-side & lt; Script type = "text / javascript" & gt; Function Pageload () {Sys.WebForms.PageRequestManager.getInstance () add_endRequest (onEndRequest); } Function on endurext (sender, args) {var lbl = document.getElementById ("Label1"); Lbl.innerHTML = argsget_error (). message; Args.set_errorHandled (true); } & Lt; / Script & gt;  

No comments:

Post a Comment