How to use different client AJAX UpdatePanel error handling for different UpdatePanels?

I have an ASP.NET AJAX page with several UpdatePanels. If error occured during asyncronous postback, I want to ignore it for some panels and show errors for other updatepanels. The samples that I found(like  Customizing Error Handling for ASP.NET UpdatePanel Controls.) suggested to call add_endRequest and from EndRequestEventArgs  use error Property  .

 Dave Ward suggested that In EndRequest, you can check sender._panelsToRefreshIDs. It’s a JavaScript array of UpdatePanel IDs being updated in the partial postback

My question on forum is how can I find which of UpdatePanels caused the particular Request in EndRequestHandler?

I found an idea in comments of How to handle a timeout in an async postback to use response Property (Sys.Net.WebRequestExecutor class.) Then I can access webRequest Property , but what to do next?

Jin-Yu Yin from MSFT  suggested to follow these steps:

1. Get which UpdatePanel is updating at the server side. Check these links:

UpdatePanel.IsInPartialRendering Property

Gets a value that indicates whether the UpdatePanel control is being updated as a result of an asynchronous postback.

The IsInPartialRendering property is intended for use by control developers who want to know when an UpdatePanel control is being updated as a result of an asynchronous postback.

Which UpdatePanel issued an Async Postback Call?

how to get which UpdatePanel has posted

2. use try… catch to catch errors, and in catch block, create an new exception which contain information of which updatepanel is updating and throw it.

3. check the information in the error at the client side, process the error based on the information

 

Advertisements