|
Article relates to
|
RadComboBox, RadTreeView, etc.
|
|
Last modified
|
8/11/2010
|
|
Last modified by
|
8/11/2010
|
THE ISSUE
The ASP.NET AJAX framework’s callback mechanism is designed to process only three types of responses from the server:
- Success
- AJAX Exception
- ASP.NET Exception
Each of these responses is formatted in a specific way so that the client-side script processing the callback recognizes them and decides which events to rise in each case. If, however, the server returns something different, for instance an HTTP status code indicating a redirection or
401 Unauthorized/403 Forbidden, the ASP.NET AJAX script does not know what to do, hence nothing happens in response to this callback.
Since RadControls are based on the ASP.NET AJAX Framework it is clear that if the same as above happens during a Load on Demand request, the control will ‘hang’. For instance RadcomboBox will remain open saying ‘Loading…’ indefinitely:
THE SOLUTION
In this specific case, the ASP.NET AJAX client-side framework does not allow much to be done through its API in an elegant manner. This is why the only way to work around this limitation is to ‘patch’ the function that decides which events to rise based on the response of the callback, namely WebForm_ExecuteCallback. Below is the code that you can put on your page after the ScriptManager on the page:
The code simply overrides the original version of the function and raises the same event which it raises when it receives an Exception-response.
Now RadComboBox will alert the status code of the response and will not hang. If you then handle the client-side ItemsRequestFailed event, you can access the status code and the response from the event arguments and/or cancel the event to suppress the alert and take necessary action, for instance redirect the browser:
Note: The event you can use with RadTreeView is NodePopulationFailed. The only difference is that you have access to the status code (again through eventArgs.get_errorMessage()) and not to the response.
You can see how this works in the attached project.
Please
Sign In
to rate this article.