Thursday, August 7, 2008

'AjaxControlToolKit' Undefined.

I was trying to use the DateExtender control from AjaxControlToolKit. I did everything right but there was a javascript error saying that AjaxControlToolKit is undefined. I did a googling and found that it is because of my system date which was pointing to Feb 2, 2002. I changed this to current date Aug 07, 2008 and also the selectedDate property of the DateExtender.
Then this error was not coming and it is working perfectly.

Monday, July 7, 2008

Custom error handling for Microsoft Ajax 1.0 with Javascript

Cause
I was facing problem while handling the exception thrown by ajax 1.0 . I put sometime and find the following way out.
Solution
Understood that i need to add an custom event to the endRequest, this should be done in the body onload.
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

Then after that we need to check whether the event arguments has an error or not. As follows
function EndRequestHandler(sender, args)
{
if (args.get_error() != undefined && args.get_error().httpStatusCode == '500')
{

//Handle the exception here.
var errorMessage = args.get_error().message
args.set_errorHandled(true);
}
}

This is a simple and very handy way to handle the exception for Ajax 1.0.