How to: Implement Callbacks in ASP.NET Web Pages

In a client callback, a client script function sends a request to the ASP.NET Web page, which then runs an abbreviated version of its normal life cycle to process the callback. To ensure that callback events originate from the expected user interface (UI), you can validate callbacks. In callback validation, you register an event for validation during the Web page rendering and then validate the event during the callback. For an overview of callbacks, see Implementing Client Callbacks Programmatically Without Postbacks in ASP.NET Web Pages.

To implement the ICallBackEventHandler interface

  1. For a single-file page or user control, implement the ICallbackEventHandler interface using an @ Implements directive in the page, as shown in the following example.

    No code example is currently available or this language may not be supported.
    Note Note

    If you are using a code-behind page model, implement the ICallbackEventHandler interface for your partial class.

  2. Implement the RaiseCallbackEvent method of the ICallbackEventHandler interface. The RaiseCallbackEvent method takes a single argument that represents the event arguments, as shown in the following example.

    No code example is currently available or this language may not be supported.
  3. Implement the GetCallbackResult method of the ICallbackEventHandler interface. The GetCallbackResult method takes no arguments and returns a string that represents the result of the callback. In the following example, a string called returnValue is returned.

    No code example is currently available or this language may not be supported.

To register the callback for event validation

To validate the callback and return the callback result

Show: