This is a migrated thread and some comments may be shown as answers.

How can I handle Exception with Ajax Reponse?

1 Answer 63 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
King Chan
Top achievements
Rank 1
King Chan asked on 07 Mar 2011, 06:19 PM
Hello,

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.

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 10 Mar 2011, 04:09 PM
Hello,

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.

Greetings,
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!
Tags
Ajax
Asked by
King Chan
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or