Exception handling in Ajax is done using the ‘ErrorTemplate’ which forms the child tag of ‘ScriptManager’. There are three steps to achieve error handling in Ajax. Below figure ‘ErrorHandling’ in Ajax shows the three steps in a pictorial fashion.
Figure 18.16:- Error Handling in Ajax
- Step 1 -> Right click on the script manager and click ‘Create Error Template’.
- Step 2 -> Once done click on ‘Edit Templates’.
- Step 3 -> Enter which error message you want to display when there is a error and then finally click ‘End Template Editing’.
Just click back on the HTML view to see what we have in the HTML. You can see the ‘ErrorTemplate’ tag is the fundamental driver for handling errors.
Asked In: Many Interviews |