How can I handle Exception with Ajax Reponse?

2 posts, 0 answers
  1. King Chan
    King Chan avatar
    30 posts
    Member since:
    Feb 2010

    Posted 07 Mar 2011 Link to this post


    I am new to ASP.Net Ajax and Telerik component.
    I made a page that use Telerik Ajax Manager, Ajax Panel that contains a form for user to enter user name and password for login.

    When user click submit, the Ajax Panel will do a postback, and only reload the Ajax Panel's content to check if is correct user name and password.

    The problem is, there should be an exception throw during the checking user name and password process during the postback. (Because for some reason, the data table missing a field and it throw exception).
    When I do that in internet explorer, the page just post back normally (with the form that let user enter user name and password) and not login.
    But when I do it in Visual Studio, the exception will throw in during the postback.

    So is there a way I can handle if there is any exception throw during Ajax postback on any page globally and redirect to an error page?
    Or display error on the page?
    I tried to use try catch then Response.Write to print out the error but it doesn't work well....

    Any example would be a great help.

    Thanks in advance.
  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 10 Mar 2011 Link to this post


    I would suggest you to try setting the AsyncPostBackErrorMessage property, which is the error message that is sent to the browser.
    I hope this helps.

    Maria Ilieva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top