Tuesday, January 10, 2006 12:44 PM
Client Script Call Back is one of the coolest features in ASP.NET 2.0. The idea of client side refresh in the data wherein the server side execution happens in Remote scripting is a huge leap towards the scalability of web applications. Remote scripting has been around for quite a while in different forms such as Remote Scripting Core, Ajax, Atlas, Client Script Call Back etc., They all have one basic advantage. In order to communicate with the Server, the page doesnt have to do a postback. This avoids the ugly flash and controls state retaining problem.
While implementing Client Script Call Back, you may receive the error "The target '__Page' for the callback could not be found or did not implement ICallbackEventHandler."
This error occurs, if you miss to specify the ICallBackEventHandler Interface in your Page Inheritance.
The typical Code behind class for an ASP.NET 2.0 Webform looks as below:-
public partial class _Default : System.Web.UI.Page
However, in the case of implementing Client Script Call Back, we also need to specify the Interface as follows:-
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
This specifies that the page implements ICallBackEventHandler interface and can implement client side scripting call backs to the server side code.
This setting might just be overlooked when we create the page since, the partial class declaration code is added by default and we always resort to start writing our code from the Page_Load event and other events and dont interfere with the auto generated code such as the class definition. The ICallbackEventHandler is not added by default. It has to be explicitly specified as mentioned above.
This would resolve your issue.
Cheers and Happy Programming !!!